Magento 2 REST API客户自定义属性 [英] Magento 2 REST API Customer Custom Attribute
问题描述
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": "someone@exaxmple.com",
"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
是现有的开箱即用属性-OOTB属性名称-值映射分配将具有优先权
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客户自定义属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!