7

When I try to update a product, created via the REST V1 API, only the values are updated for de default website. Unfortunattely I can't find any possibility to send website id's within te json. Does anyone have experienced this before?

The data I send for the update to /V1/products/123456:

{"product":{"sku":"123456","name":"D4D0123299","price":21,"type_id":"simple","custom_attributes":[],"extension_attributes":{"stock_item":{"use_config_manage_stock":1}}}}"

Linking the product to specific websites is done with a second request, after creating it via /V1/products, to /V1/products/123456/websites (POST) with this data foreach website:

"{"productWebsiteLink":{"sku":"D4D01232","websiteId":1}}"
"{"productWebsiteLink":{"sku":"D4D01232","websiteId":2}}"

The Magento 2 version is 2.1.0

Emizen Tech
  • 3,529
  • 1
  • 17
  • 33
MmynameStackflow
  • 1,251
  • 3
  • 19
  • 39

1 Answers1

7

Magento2 always set default store while PUT or POST API Calls

to save values with ref to Store you can use like following

API URL

http://yourmagento2store.com/rest/default/V1/products/123456

where default is the store code

you can also use admin if you want to update @ Admin level not store level.

http://yourmagento2store.com/rest/admin/V1/products/123456

if you need any custom than you can also refer to Magento2: REST API : Save Product Detail per store view not working

Community
  • 1
  • 1
Emizen Tech
  • 3,529
  • 1
  • 17
  • 33
  • Is there a way to change for example the productname for alle stores in one PUT request? Or a way to update the whole product for all stores in one PUT request? – MmynameStackflow Dec 15 '16 at 07:58
  • When I do the request to http://yourmagento2store.com/rest/admin/V1/products/123456 I get the following response: Client error: `PUT http://yourmagento2store.com/rest/admin/V1/products/123456` resulted in a `404 Not Found` response: {"message":"Request does not match any route."} It didn't work the way you suggested. Are you sure this should work for Magento 2? I also couldn't find any documentation about this. – MmynameStackflow Dec 15 '16 at 10:51
  • Same for yourmagento2store.com/rest/0/V1/products/123456 by the way – MmynameStackflow Dec 16 '16 at 10:03
  • 0 is admin store id : use "admin" as : yourmagento2store.com/rest/admin/V1/products/123456 – Miss Mage Dec 26 '16 at 07:42
  • also if this is not working you can try with this solution mentioned in http://stackoverflow.com/questions/37744874/magento2-rest-api-save-product-detail-per-store-view-not-working/37875681#37875681 and use store id in URL Parameter – Miss Mage Dec 26 '16 at 07:43
  • How to get the custom attributes ids in an the products' api response. I am getting only two parameters `"attribute_code": "options_container", "value": "container2"`. My API call is https://mydomain/rest/V1/products?searchCriteria[currentPage]=1 – Parthiv Apr 18 '18 at 12:30