Plugins 如何拓展Shopware客户群
我需要编写一个Shopware插件,用Plugins 如何拓展Shopware客户群,plugins,e-commerce,shopware,Plugins,E Commerce,Shopware,我需要编写一个Shopware插件,用external\u id字段扩展客户模型。此字段应可通过管理UI和API进行编辑 我发现,我可以像这样为用户添加属性: public function addAttributes() { $this->Application()->Models()->addAttribute( 's_user_attributes', 'bla', 'externalId', 'IN
external\u id
字段扩展客户模型。此字段应可通过管理UI和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对于后端,您必须执行一些操作 对于API,您必须扩展:
addAttribute
在Shopware 5中不推荐使用。
改用shopware()
-容器中的shopware\u属性.crud\u服务
$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
,则可以在用户所在的后端对其进行编辑
更多信息请访问。第二个链接不再有效。这就是为什么你发布完整的代码参考,而不仅仅是链接!