removing categorty in product page is giving errorMagento2: Could not save product “330664” with position...

Why did C use the -> operator instead of reusing the . operator?

How do I check if a string is entirely made of the same substring?

On The Origin of Dissonant Chords

Do I have an "anti-research" personality?

Could the terminal length of components like resistors be reduced?

Retract an already submitted recommendation letter (written for an undergrad student)

Which big number is bigger?

Can someone publish a story that happened to you?

How do I reattach a shelf to the wall when it ripped out of the wall?

A ​Note ​on ​N!

Apparently, my CLR assembly function is causing deadlocks?

Was there a shared-world project before "Thieves World"?

"The cow" OR "a cow" OR "cows" in this context

What happens to Mjolnir (Thor's hammer) at the end of Endgame?

What makes accurate emulation of old systems a difficult task?

Minor Revision with suggestion of an alternative proof by reviewer

Can't get 5V 3A DC constant

How can I print the prosodic symbols in LaTeX?

Mistake in years of experience in resume?

How can I practically buy stocks?

How much cash can I safely carry into the USA and avoid civil forfeiture?

Is there really no use for MD5 anymore?

Re-entry to Germany after vacation using blue card

"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?



removing categorty in product page is giving error


Magento2: Could not save product “330664” with position 0 to category 3567How to solve the error : “Could not save product ”20072“ with position 0 to category 7” in magento 2Magento 2.2.4: Could not save product “3395” with position 1 to category 1882Magento 2 Cannot save product (Invalid option value)Get product number in categoryMagento 2: How to Set Bulk Product Position in Category?Magento reindexingMageto2 product listing page random productJS error on product page Cannot read property '' of undefined _getAttributeCodeById which doesnt allow to load configrable price and imageProduct category update issue in magento2Magento 2.2.3 CE unable to add/remove item from wishlist?Magento 2 breadcrumbs issue on product view page?Magento 2.2.4: Could not save product “3395” with position 1 to category 1882






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







-1















We are facing issues - https://prnt.sc/mgdybf why we are not able to remove the Deal and Pre Owned category.






Could not save product "26652" with position 0 to category 435






What is this error message about? How to solve this issue?



Regards
Rachna










share|improve this question























  • Possible duplicate of How to solve the error : "Could not save product "20072" with position 0 to category 7" in magento 2

    – sv3n
    33 mins ago











  • Or magento.stackexchange.com/questions/213541/…

    – sv3n
    31 mins ago


















-1















We are facing issues - https://prnt.sc/mgdybf why we are not able to remove the Deal and Pre Owned category.






Could not save product "26652" with position 0 to category 435






What is this error message about? How to solve this issue?



Regards
Rachna










share|improve this question























  • Possible duplicate of How to solve the error : "Could not save product "20072" with position 0 to category 7" in magento 2

    – sv3n
    33 mins ago











  • Or magento.stackexchange.com/questions/213541/…

    – sv3n
    31 mins ago














-1












-1








-1








We are facing issues - https://prnt.sc/mgdybf why we are not able to remove the Deal and Pre Owned category.






Could not save product "26652" with position 0 to category 435






What is this error message about? How to solve this issue?



Regards
Rachna










share|improve this question














We are facing issues - https://prnt.sc/mgdybf why we are not able to remove the Deal and Pre Owned category.






Could not save product "26652" with position 0 to category 435






What is this error message about? How to solve this issue?



Regards
Rachna







magento2 product category indexing






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 7 at 13:13









Rachna ThakurRachna Thakur

365




365













  • Possible duplicate of How to solve the error : "Could not save product "20072" with position 0 to category 7" in magento 2

    – sv3n
    33 mins ago











  • Or magento.stackexchange.com/questions/213541/…

    – sv3n
    31 mins ago



















  • Possible duplicate of How to solve the error : "Could not save product "20072" with position 0 to category 7" in magento 2

    – sv3n
    33 mins ago











  • Or magento.stackexchange.com/questions/213541/…

    – sv3n
    31 mins ago

















Possible duplicate of How to solve the error : "Could not save product "20072" with position 0 to category 7" in magento 2

– sv3n
33 mins ago





Possible duplicate of How to solve the error : "Could not save product "20072" with position 0 to category 7" in magento 2

– sv3n
33 mins ago













Or magento.stackexchange.com/questions/213541/…

– sv3n
31 mins ago





Or magento.stackexchange.com/questions/213541/…

– sv3n
31 mins ago










2 Answers
2






active

oldest

votes


















1














Update



Some people have faced this issue already and have a solution. Check these posts



Magento2: Could not save product "330664" with position 0 to category 3567



https://github.com/magento/magento2/issues/8970



The error is from the CategoryLinkRepository File from module-catalog which handles the save functionality. Check your exception log for more details, which tells you exactly why you couldn't save the product. Hope am pointing you to the right direction. Check also deleteByIds method, it can be the potential cause of this issue.



/**
* {@inheritdoc}
*/
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];
unset($productPositions[$productID]);

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



magentovendormagentomodule-catalogModelCategoryLinkRepository.php




/**
* {@inheritdoc}
*/
public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
{
$category = $this->categoryRepository->get($productLink->getCategoryId());
$product = $this->productRepository->get($productLink->getSku());
$productPositions = $category->getProductsPosition();
$productPositions[$product->getId()] = $productLink->getPosition();
$category->setPostedProducts($productPositions);
try {
$category->save();
} catch (Exception $e) {
throw new CouldNotSaveException(
__(
'Could not save product "%1" with position %2 to category %3',
$product->getId(),
$productLink->getPosition(),
$category->getId()
),
$e
);
}
return true;
}





share|improve this answer

































    -1














    In my case I put the erorr message within the returned string



    vendor/magento/module-catalog/Model/CategoryLinkRepository.php



    public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
    {
    $category = $this->categoryRepository->get($productLink->getCategoryId());
    $product = $this->productRepository->get($productLink->getSku());
    $productPositions = $category->getProductsPosition();
    $productPositions[$product->getId()] = $productLink->getPosition();
    $category->setPostedProducts($productPositions);
    try {
    $category->save();
    } catch (Exception $e) {
    throw new CouldNotSaveException(
    __(
    'Could not save product "%1" with position %2 to category %3 : error %4',
    $product->getId(),
    $productLink->getPosition(),
    $category->getId(),
    $e->getMessage()
    ),
    $e
    );
    }
    return true;
    }


    The error was about unique integrity in the database.



    And sure enough there were duplicate category IDs in an array I was providing for linking products to categories



    public function __construct(
    MagentoCatalogApiCategoryLinkManagementInterface $categoryLinkManagementInterface
    ) {
    $this->categoryLinkManagementInterface = $categoryLinkManagementInterface;
    }

    /**
    * Assign product to category
    * @param MagentoCatalogModelProduct $product
    * @param array $categoryIds
    * @return void
    */
    public function assignProductToCategory($product, $categoryIds = [])
    {
    if(!empty($categoryIds)) {
    $this->categoryLinkManagementInterface->assignProductToCategories(
    $product->getSku(),
    $categoryIds
    );
    }
    }





    share|improve this answer
























    • FYI: I'v downvoted all duplicate answers and upvoted one. If you delete them REP points are restored. If you want to help and find duplicate question, please post you answer to the oldest/most active and flag the others as duplicate. This helps to keep the board clean. Thanks :)

      – sv3n
      7 mins ago












    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f260866%2fremoving-categorty-in-product-page-is-giving-error%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Update



    Some people have faced this issue already and have a solution. Check these posts



    Magento2: Could not save product "330664" with position 0 to category 3567



    https://github.com/magento/magento2/issues/8970



    The error is from the CategoryLinkRepository File from module-catalog which handles the save functionality. Check your exception log for more details, which tells you exactly why you couldn't save the product. Hope am pointing you to the right direction. Check also deleteByIds method, it can be the potential cause of this issue.



    /**
    * {@inheritdoc}
    */
    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];
    unset($productPositions[$productID]);

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



    magentovendormagentomodule-catalogModelCategoryLinkRepository.php




    /**
    * {@inheritdoc}
    */
    public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
    {
    $category = $this->categoryRepository->get($productLink->getCategoryId());
    $product = $this->productRepository->get($productLink->getSku());
    $productPositions = $category->getProductsPosition();
    $productPositions[$product->getId()] = $productLink->getPosition();
    $category->setPostedProducts($productPositions);
    try {
    $category->save();
    } catch (Exception $e) {
    throw new CouldNotSaveException(
    __(
    'Could not save product "%1" with position %2 to category %3',
    $product->getId(),
    $productLink->getPosition(),
    $category->getId()
    ),
    $e
    );
    }
    return true;
    }





    share|improve this answer






























      1














      Update



      Some people have faced this issue already and have a solution. Check these posts



      Magento2: Could not save product "330664" with position 0 to category 3567



      https://github.com/magento/magento2/issues/8970



      The error is from the CategoryLinkRepository File from module-catalog which handles the save functionality. Check your exception log for more details, which tells you exactly why you couldn't save the product. Hope am pointing you to the right direction. Check also deleteByIds method, it can be the potential cause of this issue.



      /**
      * {@inheritdoc}
      */
      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];
      unset($productPositions[$productID]);

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



      magentovendormagentomodule-catalogModelCategoryLinkRepository.php




      /**
      * {@inheritdoc}
      */
      public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
      {
      $category = $this->categoryRepository->get($productLink->getCategoryId());
      $product = $this->productRepository->get($productLink->getSku());
      $productPositions = $category->getProductsPosition();
      $productPositions[$product->getId()] = $productLink->getPosition();
      $category->setPostedProducts($productPositions);
      try {
      $category->save();
      } catch (Exception $e) {
      throw new CouldNotSaveException(
      __(
      'Could not save product "%1" with position %2 to category %3',
      $product->getId(),
      $productLink->getPosition(),
      $category->getId()
      ),
      $e
      );
      }
      return true;
      }





      share|improve this answer




























        1












        1








        1







        Update



        Some people have faced this issue already and have a solution. Check these posts



        Magento2: Could not save product "330664" with position 0 to category 3567



        https://github.com/magento/magento2/issues/8970



        The error is from the CategoryLinkRepository File from module-catalog which handles the save functionality. Check your exception log for more details, which tells you exactly why you couldn't save the product. Hope am pointing you to the right direction. Check also deleteByIds method, it can be the potential cause of this issue.



        /**
        * {@inheritdoc}
        */
        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];
        unset($productPositions[$productID]);

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



        magentovendormagentomodule-catalogModelCategoryLinkRepository.php




        /**
        * {@inheritdoc}
        */
        public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
        {
        $category = $this->categoryRepository->get($productLink->getCategoryId());
        $product = $this->productRepository->get($productLink->getSku());
        $productPositions = $category->getProductsPosition();
        $productPositions[$product->getId()] = $productLink->getPosition();
        $category->setPostedProducts($productPositions);
        try {
        $category->save();
        } catch (Exception $e) {
        throw new CouldNotSaveException(
        __(
        'Could not save product "%1" with position %2 to category %3',
        $product->getId(),
        $productLink->getPosition(),
        $category->getId()
        ),
        $e
        );
        }
        return true;
        }





        share|improve this answer















        Update



        Some people have faced this issue already and have a solution. Check these posts



        Magento2: Could not save product "330664" with position 0 to category 3567



        https://github.com/magento/magento2/issues/8970



        The error is from the CategoryLinkRepository File from module-catalog which handles the save functionality. Check your exception log for more details, which tells you exactly why you couldn't save the product. Hope am pointing you to the right direction. Check also deleteByIds method, it can be the potential cause of this issue.



        /**
        * {@inheritdoc}
        */
        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];
        unset($productPositions[$productID]);

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



        magentovendormagentomodule-catalogModelCategoryLinkRepository.php




        /**
        * {@inheritdoc}
        */
        public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
        {
        $category = $this->categoryRepository->get($productLink->getCategoryId());
        $product = $this->productRepository->get($productLink->getSku());
        $productPositions = $category->getProductsPosition();
        $productPositions[$product->getId()] = $productLink->getPosition();
        $category->setPostedProducts($productPositions);
        try {
        $category->save();
        } catch (Exception $e) {
        throw new CouldNotSaveException(
        __(
        'Could not save product "%1" with position %2 to category %3',
        $product->getId(),
        $productLink->getPosition(),
        $category->getId()
        ),
        $e
        );
        }
        return true;
        }






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 7 at 13:38

























        answered Feb 7 at 13:33









        HaijeromeHaijerome

        1,0661119




        1,0661119

























            -1














            In my case I put the erorr message within the returned string



            vendor/magento/module-catalog/Model/CategoryLinkRepository.php



            public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
            {
            $category = $this->categoryRepository->get($productLink->getCategoryId());
            $product = $this->productRepository->get($productLink->getSku());
            $productPositions = $category->getProductsPosition();
            $productPositions[$product->getId()] = $productLink->getPosition();
            $category->setPostedProducts($productPositions);
            try {
            $category->save();
            } catch (Exception $e) {
            throw new CouldNotSaveException(
            __(
            'Could not save product "%1" with position %2 to category %3 : error %4',
            $product->getId(),
            $productLink->getPosition(),
            $category->getId(),
            $e->getMessage()
            ),
            $e
            );
            }
            return true;
            }


            The error was about unique integrity in the database.



            And sure enough there were duplicate category IDs in an array I was providing for linking products to categories



            public function __construct(
            MagentoCatalogApiCategoryLinkManagementInterface $categoryLinkManagementInterface
            ) {
            $this->categoryLinkManagementInterface = $categoryLinkManagementInterface;
            }

            /**
            * Assign product to category
            * @param MagentoCatalogModelProduct $product
            * @param array $categoryIds
            * @return void
            */
            public function assignProductToCategory($product, $categoryIds = [])
            {
            if(!empty($categoryIds)) {
            $this->categoryLinkManagementInterface->assignProductToCategories(
            $product->getSku(),
            $categoryIds
            );
            }
            }





            share|improve this answer
























            • FYI: I'v downvoted all duplicate answers and upvoted one. If you delete them REP points are restored. If you want to help and find duplicate question, please post you answer to the oldest/most active and flag the others as duplicate. This helps to keep the board clean. Thanks :)

              – sv3n
              7 mins ago
















            -1














            In my case I put the erorr message within the returned string



            vendor/magento/module-catalog/Model/CategoryLinkRepository.php



            public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
            {
            $category = $this->categoryRepository->get($productLink->getCategoryId());
            $product = $this->productRepository->get($productLink->getSku());
            $productPositions = $category->getProductsPosition();
            $productPositions[$product->getId()] = $productLink->getPosition();
            $category->setPostedProducts($productPositions);
            try {
            $category->save();
            } catch (Exception $e) {
            throw new CouldNotSaveException(
            __(
            'Could not save product "%1" with position %2 to category %3 : error %4',
            $product->getId(),
            $productLink->getPosition(),
            $category->getId(),
            $e->getMessage()
            ),
            $e
            );
            }
            return true;
            }


            The error was about unique integrity in the database.



            And sure enough there were duplicate category IDs in an array I was providing for linking products to categories



            public function __construct(
            MagentoCatalogApiCategoryLinkManagementInterface $categoryLinkManagementInterface
            ) {
            $this->categoryLinkManagementInterface = $categoryLinkManagementInterface;
            }

            /**
            * Assign product to category
            * @param MagentoCatalogModelProduct $product
            * @param array $categoryIds
            * @return void
            */
            public function assignProductToCategory($product, $categoryIds = [])
            {
            if(!empty($categoryIds)) {
            $this->categoryLinkManagementInterface->assignProductToCategories(
            $product->getSku(),
            $categoryIds
            );
            }
            }





            share|improve this answer
























            • FYI: I'v downvoted all duplicate answers and upvoted one. If you delete them REP points are restored. If you want to help and find duplicate question, please post you answer to the oldest/most active and flag the others as duplicate. This helps to keep the board clean. Thanks :)

              – sv3n
              7 mins ago














            -1












            -1








            -1







            In my case I put the erorr message within the returned string



            vendor/magento/module-catalog/Model/CategoryLinkRepository.php



            public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
            {
            $category = $this->categoryRepository->get($productLink->getCategoryId());
            $product = $this->productRepository->get($productLink->getSku());
            $productPositions = $category->getProductsPosition();
            $productPositions[$product->getId()] = $productLink->getPosition();
            $category->setPostedProducts($productPositions);
            try {
            $category->save();
            } catch (Exception $e) {
            throw new CouldNotSaveException(
            __(
            'Could not save product "%1" with position %2 to category %3 : error %4',
            $product->getId(),
            $productLink->getPosition(),
            $category->getId(),
            $e->getMessage()
            ),
            $e
            );
            }
            return true;
            }


            The error was about unique integrity in the database.



            And sure enough there were duplicate category IDs in an array I was providing for linking products to categories



            public function __construct(
            MagentoCatalogApiCategoryLinkManagementInterface $categoryLinkManagementInterface
            ) {
            $this->categoryLinkManagementInterface = $categoryLinkManagementInterface;
            }

            /**
            * Assign product to category
            * @param MagentoCatalogModelProduct $product
            * @param array $categoryIds
            * @return void
            */
            public function assignProductToCategory($product, $categoryIds = [])
            {
            if(!empty($categoryIds)) {
            $this->categoryLinkManagementInterface->assignProductToCategories(
            $product->getSku(),
            $categoryIds
            );
            }
            }





            share|improve this answer













            In my case I put the erorr message within the returned string



            vendor/magento/module-catalog/Model/CategoryLinkRepository.php



            public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
            {
            $category = $this->categoryRepository->get($productLink->getCategoryId());
            $product = $this->productRepository->get($productLink->getSku());
            $productPositions = $category->getProductsPosition();
            $productPositions[$product->getId()] = $productLink->getPosition();
            $category->setPostedProducts($productPositions);
            try {
            $category->save();
            } catch (Exception $e) {
            throw new CouldNotSaveException(
            __(
            'Could not save product "%1" with position %2 to category %3 : error %4',
            $product->getId(),
            $productLink->getPosition(),
            $category->getId(),
            $e->getMessage()
            ),
            $e
            );
            }
            return true;
            }


            The error was about unique integrity in the database.



            And sure enough there were duplicate category IDs in an array I was providing for linking products to categories



            public function __construct(
            MagentoCatalogApiCategoryLinkManagementInterface $categoryLinkManagementInterface
            ) {
            $this->categoryLinkManagementInterface = $categoryLinkManagementInterface;
            }

            /**
            * Assign product to category
            * @param MagentoCatalogModelProduct $product
            * @param array $categoryIds
            * @return void
            */
            public function assignProductToCategory($product, $categoryIds = [])
            {
            if(!empty($categoryIds)) {
            $this->categoryLinkManagementInterface->assignProductToCategories(
            $product->getSku(),
            $categoryIds
            );
            }
            }






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 42 mins ago









            Dominic XigenDominic Xigen

            454




            454













            • FYI: I'v downvoted all duplicate answers and upvoted one. If you delete them REP points are restored. If you want to help and find duplicate question, please post you answer to the oldest/most active and flag the others as duplicate. This helps to keep the board clean. Thanks :)

              – sv3n
              7 mins ago



















            • FYI: I'v downvoted all duplicate answers and upvoted one. If you delete them REP points are restored. If you want to help and find duplicate question, please post you answer to the oldest/most active and flag the others as duplicate. This helps to keep the board clean. Thanks :)

              – sv3n
              7 mins ago

















            FYI: I'v downvoted all duplicate answers and upvoted one. If you delete them REP points are restored. If you want to help and find duplicate question, please post you answer to the oldest/most active and flag the others as duplicate. This helps to keep the board clean. Thanks :)

            – sv3n
            7 mins ago





            FYI: I'v downvoted all duplicate answers and upvoted one. If you delete them REP points are restored. If you want to help and find duplicate question, please post you answer to the oldest/most active and flag the others as duplicate. This helps to keep the board clean. Thanks :)

            – sv3n
            7 mins ago


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f260866%2fremoving-categorty-in-product-page-is-giving-error%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            迭戈·戈丁...

            A phrase ”follow into" in a context The 2019 Stack Overflow Developer Survey Results Are...

            1960s short story making fun of James Bond-style spy fiction The 2019 Stack Overflow Developer...