我正在研究Magento2 v2.4产品集成用例。
我正在使用 postman创建一个REST API product,并观察到在请求JSON中存在产品、颜色属性,但在从Magento接收的响应中缺少这些属性。
POST http://localhost/magento2/rest/V1/products
Request:
{
"product": {
"id": "2007",
"sku": "20210004",
"name": "Iphone 4",
"price": "400",
"status": 1,
"extension_attributes": {
"stock_item": {
"qty": 4,
"is_in_stock": "true"
}
},
"custom_attributes": [
{
"attribute_code": "color",
"value": 4
}
]
}
}
Response:
{
"id": 2007,
"sku": "20210004",
"name": "Iphone 4",
"attribute_set_id": 4,
"status": 1,
"visibility": 4,
"extension_attributes": {
"stock_item": {
"item_id": 18,
"product_id": 2007,
"stock_id": 1,
"qty": 4,
"is_in_stock": true,
"is_qty_decimal": false
}
},
"custom_attributes": [
{
"attribute_code": "options_container",
"value": "container2"
},
{
"attribute_code": "url_key",
"value": "iphone-4"
}
]
}如果您查看请求和响应有效负载,您将看到价格和颜色在那里的请求,但不知怎的Magento没有尊重这些,并被错过了回应。
如果我想使这个工作,我不得不再次发送相同的有效载荷。然后我可以看到价格和颜色作为回应。
你能建议一下这里有什么问题吗?
发布于 2021-08-12 09:10:54
这可以归结为Magento (https://github.com/magento/magento2/issues/13639)中的一个bug。
在编写本报告时,这一问题应在2.4.3中加以修正。对于版本2.4.2和更低的版本,您可以在有效负载中添加以下内容:
"type_id": "simple"
https://stackoverflow.com/questions/67607571
复制相似问题