Magento 2-REST API PUT产品 [英] Magento 2 - REST API PUT product

查看:238
本文介绍了Magento 2-REST API PUT产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试更新通过REST V1 API创建的产品时,仅默认网站的值被更新.不幸的是,我找不到在json中发送网站ID的任何可能性.有人曾经经历过吗?

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?

我发送给/V1/products/123456更新的数据:

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}}}}"

在通过/V1/products创建产品后,通过第二个请求将产品链接到特定网站,并使用每个网站的以下数据将其链接到/V1/products/123456/websites(POST):

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}}"

Magento 2 版本是 2.1.0

推荐答案

在PUT或POST API调用时,Magento2始终设置默认存储

Magento2 always set default store while PUT or POST API Calls

要使用存储"来保存值,您可以按照以下方式使用

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

API网址

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

其中默认是商店代码

如果要更新@管理员级别而不是存储级别,也可以使用 admin .

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

这篇关于Magento 2-REST API PUT产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆