I want to add the company name to the customer grid, when you create a new order in the admin panel.
Therefore I created the following module, but there is no field with company name added to the grid.
What am I missing here?
app/code/Vendor/Module/view/adminhtml/layout/sales_order_create_customer_block.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="adminhtml.customer.grid.container">
<arguments>
<argument name="dataSource" xsi:type="object">\Vendor\ Module\Model\ResourceModel\Order\Customer\Collection</argument>
</arguments>
</referenceBlock>
<referenceBlock name="adminhtml.customer.grid.columnSet">
<block class="Magento\Backend\Block\Widget\Grid\Column" as="company" after="billing_postcode">
<arguments>
<argument name="header" xsi:type="string" translate="true">Company</argument>
<argument name="index" xsi:type="string">company</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
app/code/Vendor/Module/Model/ResourceModel/Order/Customer/Collection.php
<?php
namespace Vendor\Module\Model\ResourceModel\Order\Customer;
class Collection extends \Magento\Sales\Model\ResourceModel\Order\Customer\Collection
{
/**
* @return $this
*/
protected function _initSelect()
{
parent::_initSelect();
$this->joinAttribute(
'company',
'customer_address/company',
'default_billing',
null,
'left'
);
return $this;
}
}