我需要编写一个Shopware插件,用external_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
发布于 2015-10-20 08:08:53
对于后端,您必须执行一些ExtJs编码。
对于API,您必须扩展REST-API端点供用户使用
Shopware API erweitern
发布于 2017-04-17 15:21:48
在Shopware 5中不推荐使用addAttribute。而是使用Shopware()-container中的shopware_attribute.crud_service。
$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开发者指南。
https://stackoverflow.com/questions/33169721
复制相似问题