首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Magento2RESTAPI:产品价格和自定义属性颜色没有反映出来

Magento2RESTAPI:产品价格和自定义属性颜色没有反映出来
EN

Stack Overflow用户
提问于 2021-05-19 16:51:30
回答 1查看 473关注 0票数 0

我正在研究Magento2 v2.4产品集成用例。

我正在使用 postman创建一个REST API product,并观察到在请求JSON中存在产品、颜色属性,但在从Magento接收的响应中缺少这些属性。

代码语言:javascript
复制
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没有尊重这些,并被错过了回应。

如果我想使这个工作,我不得不再次发送相同的有效载荷。然后我可以看到价格和颜色作为回应。

你能建议一下这里有什么问题吗?

EN

回答 1

Stack Overflow用户

发布于 2021-08-12 09:10:54

这可以归结为Magento (https://github.com/magento/magento2/issues/13639)中的一个bug。

在编写本报告时,这一问题应在2.4.3中加以修正。对于版本2.4.2和更低的版本,您可以在有效负载中添加以下内容:

"type_id": "simple"

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67607571

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档