[英]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.