簡體   English   中英

如何擴展Shopware客戶

[英]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開發人員指南》

對於后端,您必須執行一些ExtJs編碼

對於API,您必須為用戶擴展REST-API端點

Shopware API錯誤

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM