Magento 2 - REST API PUT product

一个人想着一个人 提交于 2020-01-23 06:19:05

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/41140175/magento-2-rest-api-put-product

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!