1

My magento installation has 3 stores (domain+language). I would like to update custom attributes for products. When I call

GET products/my_test_sku?storeId=1

i get something like the following json:

{
    "id": 1036,
    "sku": "my_test_sku",
    :
    "custom_attributes": [
        {
            "attribute_code": "question_color",
            "value": "#fa45a4"
        },
        :
    ]
}

I can not figure out how to update values for these custom attributes using some POST or PUT api call. The values are different for each storeId.

I really appreciate any help :-) Kind regards - Mikkel

3
  • Check this one . May be help for you magento.stackexchange.com/questions/255398/… Commented Apr 26, 2021 at 4:25
  • Thanks Jigar. Do you also know how you would specify the storeId when calling PUT products/attributes/{attributeCode} Commented Apr 26, 2021 at 6:39
  • Thanks Jigar. So to update the value for an attribute for a given product on a given store I call PUT {{baseurl}}/rest/{{storecode}}/V1/products/attributes/{{attributecode}} - How do I specify the product sku and attribute value? I guess they need to be placed in the body - I have tried to format some json but with no luck :-( Commented Apr 26, 2021 at 19:12

1 Answer 1

1

To answer my own question. For a multi store magento 2 setup you can update of a custom attribute for a given product like this:

PUT {{base_uri}}/rest/{{store_code}}/V1/products/{{sku}}
{
  "Product": {
    "Custom_attributes": [
      {
         "Attribute_code": "some code",
         "Value": "some value"
      }
    ]
  }
}

Thanks Jigar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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