magento 2 add company column to sale order invoice grid in backend
If you want add a custom column to sale order invoice grid, you need set value for column in data soruce of ui component.
So here is an example: how to add company column to sale order invoice grid in backend ?
1. Add “company” column to sales_order_invoice_grid in view.
<?xml version="1.0" encoding="UTF-8"?><listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"><columns name="sales_order_invoice_columns"><column name="company"><argument name="data" xsi:type="array"><item name="config" xsi:type="array"><item name="filter" xsi:type="string">text</item><item name="dataType" xsi:type="string">text</item><item name="label" xsi:type="string" translate="true">Company</item><item name="sortOrder" xsi:type="number">70</item></item></argument></column></columns></listing>
2. Create di.xml for “company” value where to get.
<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"><type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory"><arguments><argument name="collections" xsi:type="array"><item name="sales_order_invoice_grid_data_source" xsi:type="string">Tony\InvoiceCompanyColumn\Model\ResourceModel\Order\Invoice\Grid\Collection</item></argument></arguments></type></config>
3. Write some logic to model.
protected function _renderFiltersBefore(){$joinTable = $this->getTable('sales_order_address');$this->getSelect()->joinLeft($joinTable,'main_table.order_id = sales_order_address.parent_id AND sales_order_address.address_type = "billing"',['company']);parent::_renderFiltersBefore();}
After completing above steps you will see a new column named “company” will show in sale order invoice grid.
- 1 Magento ver. 2.2.0-dev - A technical prob... 16535
- 2 ECS git pull 代码很慢的问题 14669
- 3 玩客云监工客户端 13161
- 4 Magento 2 UI Form Validation 13080
- 5 Codeigniter SSL 强制重定向至https访问 12970
- 6 magento2 完整卸载模块的正确姿势 12602
- 7 Magento fix 500 12244
- 8 Magento index is locked by another reinde... 10704
- 9 Ubuntu删除日志文件 8973
- 10 Magento 2安装ElasticSearch 6.x搜索引擎-Ub... 8585