1

Updating a product with REST API with POST gives me a problem wenn I want to delete the category assignment

For example the product online is assignet into 3 categories and now I want it into 2 categories only.

So my POST would be like:

   {"product": {
        "id": 1234,
        "sku": "2345",
        "name": "Nice Product",
        "extension_attributes": {
            "website_ids": [1],
            "category_links": [{
                "position": 1,
                "category_id": "10"
            },
{
                "position": 2,
                "category_id": "11"
            }]
        }}
    }

But after this it still has assigment into 3 categories, its not deleeting the 3rd.

Btw. I have a simular question: Magento REST API Post Product and Category without "Sorting" parameter

2 Answers 2

0

I was not able to find any solution to Update the Category Entry within one POST. So the only solution was to delete them and in another POST to write the Update.

To delete Categorys Post this:

   {"product": {
        "id": 1234,
        "sku": "2345",
        "name": "Nice Product",
        "extension_attributes": {
            "website_ids": [1],
            "category_links": []
        }}
    }
1
  • this does not work
    – kexx
    Jul 30, 2021 at 19:01
0

This answer is late, but maybe it'll help someone else. I haven't found a way to change categories, but just learned that saving the product with category_links set to null, not an empty array, will remove all of them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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