This question already has an answer here:

While unasign the product from multiple categories to single category and trying to save the product, it thorow the error like below

Could not save product "20072" with position 0 to category 7

I am saving the product mannually via admin end

marked as duplicate by sv3n, Jai, Muhammad Hasham, Dhiren Vasoya, Aasim Goriya Apr 27 at 11:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Thank you for your response, I will the check then i will put tick mark – Jaisa Jun 7 '18 at 7:37

It is fixed in Magento latest version.

You can check fixes here.

  • I am using magento 2.2.2 – Jaisa Jun 7 '18 at 7:38
  • In which version it was fixed – Jaisa Jun 7 '18 at 7:38
  • it fixed in 2.2.4 @Sri – Nikunj Vadariya Jun 7 '18 at 7:39
  • hi @NikunjVadariya, I am using 2.2.4, but still error is there, – jafar pinjar Nov 24 '18 at 11:02
  • Magento 2.2.6 still happens – Beto Castillo May 6 at 20:13

To fix this issue i created a custom module.


Hope it helps.

public function deleteByIds($categoryId, $sku)
    $category = $this->categoryRepository->get($categoryId);
    $product = $this->productRepository->get($sku);
    $productPositions = $category->getProductsPosition();

    $productID = $product->getId();
    if (!isset($productPositions[$productID])) {
        throw new InputException(__('Category does not contain specified product'));
    $backupPosition = $productPositions[$productID];

    try {
    } catch (\Exception $e) {
        echo $e->getMessage();
        throw new CouldNotSaveException(
                'Could not save product "%product" with position %position to category %category',
                    "product" => $product->getId(),
                    "position" => $backupPosition,
                    "category" => $category->getId()
    return true;

the "echo $e->getMessage();" gives you the exact error. In my case it was "Duplication of URL key."

So just check what error message you are getting from here....

File: Vendor/magento/module-catalog/Model/CategoryLinkRepository.php

Not the answer you're looking for? Browse other questions tagged or ask your own question.