分类
功能

magento2 sales order grid 如何搜索显示手机号码

etc/di.xml
<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_grid_data_source" xsi:type="string">Maijindou\Sales\Plugin\ResourceModel\Order\Grid\Collection</item>
            </argument>
        </arguments>
    </type>
</config>
Maijindou\Sales\Plugin\ResourceModel\Order\Grid\Collection.php
    protected function _initSelect()
    {
        $this->addFilterToMap('billing_telephone', 'soa.telephone');
        parent::_initSelect();
    }

    protected function _renderFiltersBefore()
    {
        $this->getSelect()->joinLeft(
            ['soa' => 'sales_order_address'],
            "main_table.entity_id =soa.parent_id AND soa.address_type = 'billing'",
            ['billing_telephone'=>'soa.telephone']
        );
        parent::_renderFiltersBefore();
    }
view/adminhtml/ui_component/sales_order_grid.xml
<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_columns">
        <column name="billing_telephone">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">text</item>
                    <item name="label" xsi:type="string" translate="true">Phone Number</item>
                </item>
            </argument>
        </column>
    </columns>
</listing>