我有多个自定义字段供用户使用s_user_attributes
。我想知道是否有办法在客户的概览视图中显示它们。我知道可以创建一个不同的窗口,但是可以在默认窗口内进行吗?
有这样的文档,但我搜索的内容在那里丢失: https ://developers.shopware.com/developers-guide/backend-components/listing/
我有多个自定义字段供用户使用s_user_attributes
。我想知道是否有办法在客户的概览视图中显示它们。我知道可以创建一个不同的窗口,但是可以在默认窗口内进行吗?
有这样的文档,但我搜索的内容在那里丢失: https ://developers.shopware.com/developers-guide/backend-components/listing/
是的,可以扩展列表视图。在我的示例中billingPhone
并shippingPhone
已添加。
首先,您必须订阅以下事件:
'Enlight_Controller_Action_PostDispatchSecure_Backend_Customer' => 'onCustomerPostDispatch',
'Shopware_Controllers_Backend_CustomerQuickView::getModelFields::after' => 'addPhoneOnFields',
'Shopware_Controllers_Backend_CustomerQuickView::getListQuery::after' => 'addPhoneOnSelect',
然后必须加载数据:
public function addPhoneOnSelect(\Enlight_Hook_HookArgs $args)
{
/** @var \Shopware_Controllers_Backend_CustomerQuickView $subject */
$return = $args->getReturn();
$return->addSelect('billing.phone as billingPhone');
$return->addSelect('shipping.phone as shippingPhone');
$return->leftJoin('customer.defaultShippingAddress', 'shipping');
$args->setReturn($return);
}
public function addPhoneOnFields(\Enlight_Hook_HookArgs $args)
{
$return = $args->getReturn();
$return['billingPhone'] = ['alias' => 'billing.phone', 'type' => 'string'];
$return['shippingPhone'] = ['alias' => 'shipping.phone', 'type' => 'string'];
$args->setReturn($return);
}
然后你必须用数据扩展视图
public function onCustomerPostDispatch(Enlight_Controller_ActionEventArgs $args)
{
/** @var \Enlight_Controller_Action $controller */
$controller = $args->getSubject();
$view = $controller->View();
$request = $controller->Request();
$view->addTemplateDir(($this->container->getParameter('reply_extend_customer_overview.plugin_dir') . '/Resources/views/'));
if ($request->getActionName() == 'load') {
$view->extendsTemplate('backend/swag_extend_customer_overview/view/detail/window.js');
$view->extendsTemplate('backend/swag_extend_customer_overview/model/quick_view.js');
$view->extendsTemplate('backend/swag_extend_customer_overview/view/main/customer_list.js');
}
}
您必须像这样扩展列表的模型
// {block name="backend/customer/model/quick_view/fields" append}
{ name: 'billingPhone', type: 'string', useNull: true },
{ name: 'shippingPhone', type: 'string', useNull: true },
// {/block}
和上市
// {namespace name=backend/customer/view/main}
// {block name="backend/customer/view/main/customer_list" append}
Ext.define('Shopware.apps.SwagExtendCustomerOverview.view.main.CustomerList', {
override: 'Shopware.apps.Customer.view.main.CustomerList',
alias: 'widget.customer-list',
configure: function() {
return {
displayProgressOnSingleDelete: false,
/* {if {acl_is_allowed privilege=delete}} */
deleteButton: true,
deleteColumn: true,
/* {else} */
deleteButton: false,
deleteColumn: false,
/* {/if} */
/* {if {acl_is_allowed privilege=detail}} */
editColumn: true,
/* {else} */
editColumn: false,
/* {/if} */
/* {if {acl_is_allowed privilege=update}} */
addButton: true,
/* {else} */
addButton: false,
/* {/if} */
columns: {
active: { header: '{s name="active"}{/s}', width: 50 },
id: { header: '{s name="id"}{/s}' },
customerGroup: { header: '{s name="column/customer_group"}{/s}' },
shop: { header: '{s name="shop"}{/s}' },
number: { header: '{s name="column/number"}{/s}' },
email: { header: '{s name="email"}{/s}', renderer: this.mailRenderer, flex: 2 },
salutation: { header: '{s name="salutation"}{/s}', renderer: this.salutationRenderer },
title: { header: '{s name="title"}{/s}', width: 70 },
company: { header: '{s name="company"}{/s}' },
firstname: { header: '{s name="column/first_name"}{/s}' },
lastname: { header: '{s name="column/last_name"}{/s}' },
zipcode: { header: '{s name="zip_code"}{/s}' },
city: { header: '{s name="city"}{/s}' },
firstLogin: { header: '{s name="first_login"}{/s}' },
lastLogin: { header: '{s name="lastLogin"}{/s}' },
accountMode: { header: '{s name="column/accountMode"}{/s}', renderer: this.accountModeRenderer },
lockedUntil: { header: '{s name="lockedUntil"}{/s}' },
birthday: { header: '{s name="birthday"}{/s}' },
billingPhone: { header: '{s name="default_billing_phone_label" namespace="backend/plugins/xxx/translation"}Billing phone{/s}' },
shippingPhone: { header: '{s name="default_shipping_phone_label" namespace="backend/plugins/xxx/translation"}Billing phone{/s}' },
}
};
},
});
// {/block}