问题描述
Magento 2 REST API 文档解释了一种在更新或创建客户时为其设置 custom_attributes 的方法.http://devdocs.magento.com/swagger/index_20.html#/
The Magento 2 REST API Documentation explains a way to set custom_attributes on a customer when updating or creating it. http://devdocs.magento.com/swagger/index_20.html#/
不幸的是我无法让它工作......
Unfortunately I couldn't get this to work...
我的 POST 和 PUT JSON 请求数据是:
My POST and PUT JSON request data is :
{
"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".有没有人遇到同样的问题并解决了它?请告诉我怎么做.
The Customer is created but the Firstname is not "TEST".Is there anyone who had the same problem and fixed it? Please let me know how.
推荐答案
我最好的猜测是,因为 Firstname
是现有的 Out-Of-The-Box 属性 - OOTB 属性 name-value映射分配将优先.
My best guess is that, since Firstname
is an existing Out-Of-The-Box attribute - the OOTB attribute name-value mapping assignment will take precedence.
你能不能再试一次,用一个独特的自定义属性名称(即不与 OOTB 属性名称冲突的东西)
Could you try again, with a unique custom attribute name (i.e. something that doesn't clash with OOTB attribute names)
您需要先定义自定义客户属性,然后才能使用 M2 API 对该自定义客户属性执行操作.
You will need to DEFINE a custom-customer-attribute before you can use the M2 API to perform operations on that custom-customer-attribute.
此 StackExchange 线程 - https://magento.stackexchange.com/questions/88245/magento2-create-a-customer-custom-attribute - 提供有关如何设置自定义客户属性的其他信息.
This StackExchange thread - https://magento.stackexchange.com/questions/88245/magento2-create-a-customer-custom-attribute - has additional information on how to go about setting up a custom-customer-attribute.
这篇关于Magento 2 REST API 客户自定义属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!