Magento 2 REST API 文档解释了在更新或创建客户时设置custom_attributes 的方法。 http://devdocs.magento.com/swagger/index_20.html#/
不幸的是我无法让它发挥作用......
我的 POST 和 PUT JSON 请求数据是:
{
"customer": {
"custom_attributes": [
{
"attribute_code": "firstname",
"value": "TEST"
}
],
"email": "[email protected]",
"extension_attributes": [],
"firstname": "Someone",
"gender": null,
"lastname": "Else",
"middlename": null,
"taxvat": null,
"website_id": "1"
}
}
客户已创建,但名字不是“TEST”。 有没有人遇到同样的问题并解决了?请告诉我如何做。
我的最佳猜测是,由于
Firstname
是现有的开箱即用属性 - OOTB 属性名称-值映射分配将优先。
您可以使用唯一的自定义属性名称(即不与 OOTB 属性名称冲突的名称)再试一次吗
您需要先定义自定义客户属性,然后才能使用 M2 API 对该自定义客户属性执行操作。
此 StackExchange 线程 - https://magento.stackexchange.com/questions/88245/magento2-create-a-customer-custom-attribute - 包含有关如何设置自定义客户属性的其他信息。