[英]How to extend Shopware customer
我需要编写一个Shopware插件,以使用external_id
字段扩展客户模型。 此字段应可通过管理界面和API进行编辑。
我发现,可以像这样向用户添加属性:
public function addAttributes() {
$this->Application()->Models()->addAttribute(
's_user_attributes',
'bla',
'externalId',
'INT(11)',
true,
null
);
$this->Application()->Models()->generateAttributeModels(array(
's_user_attributes'
));
}
我应该怎么做才能在UI和API中显示此字段?
PS:Shopware 5
Shopware 5中不赞成使用addAttribute
。请shopware_attribute.crud_service
Shopware()
shopware_attribute.crud_service
中的Shopware()
。
$service = Shopware()->Container()->get('shopware_attribute.crud_service');
$service->update('s_user_attributes', 'bla', 'integer', [
'label' => '',
'supportText' => '',
'helpText' => '',
'translatable' => false,
'displayInBackend' => true,
'position' => 1
]);
Shopware()->Models()->generateAttributeModels(
array(
's_user_attributes'
)
);
如果将displayInBackend
设置为true
,则可以在用户所在的后端中对其进行编辑。
有关更多信息,请参见《 Shopware开发人员指南》 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.