1

I want to add customer billing telephone in Billing Address column in Order csv export.

Is there any setting in admin to add telephone?

Or need to override any core function for this?

1 Answer 1

3

Just tested and work on 2.2.5, you can try on 2.1.7 :)

Create custom module Custom/Module

  • In etc/di.xml

    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid">
            <arguments>
                <argument name="columns" xsi:type="array">
                    <item name="billing_telephone" xsi:type="string">sales_billing_address.telephone</item>
                </argument>
            </arguments>
        </virtualType>
    </config>
    
  • Create InstallSchema/UpgradeSchema class to add new column

    <?php
    
    namespace Custom\Module\Setup;
    
    use Magento\Framework\DB\Ddl\Table;
    use Magento\Framework\Setup\ModuleContextInterface;
    use Magento\Framework\Setup\SchemaSetupInterface;
    use Magento\Framework\Setup\InstallSchemaInterface;
    
    class InstallSchema implements InstallSchemaInterface
    {
        public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
        {
            $setup->startSetup();
    
            $setup->getConnection()->addColumn(
                $setup->getTable('sales_order_grid'),
                'billing_telephone',
                [
                    'type' => Table::TYPE_TEXT,
                    'length' => 255,
                    'comment' => 'Billing Telephone'
                ]
            );
    
            $setup->endSetup();
        }
    }
    
  • Create file Custom/Module/view/adminhtml/ui_component/sales_order_grid.xml

     <?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_columns">
            <column name="billing_telephone">
                <settings>
                    <filter>text</filter>
                    <label translate="true">Billing Telephone</label>
                    <visible>false</visible>
                </settings>
            </column>
        </columns>
    </listing>
    
3
  • I tried it, but it is not working for me. Jul 17, 2018 at 11:45
  • Have you tried to place new order? Old placed orders will not show because they missed index to sales_order_grid table
    – Quan Le
    Jul 19, 2018 at 4:50
  • Its working fine for me .. thanks @QuanLe
    – Shan
    Jul 29, 2020 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.