I created a custom module to check the ad code (measure the marketing traffic) value from the url and add to the order. I added a column to the sales order table and save the ad value when user place the order.

Now I need to show this value in the sales report.

Can someone help me how to achieve this?

  • The value should need to be in sales_order_grid right? from sales_order table Mar 13, 2019 at 5:28
  • @PrathapGunasekaran- I was thinking to add the value to report.
    – GeorgeM
    Mar 13, 2019 at 13:25
  • @PrathapGunasekaran- Yes
    – GeorgeM
    Mar 13, 2019 at 15:04
  • @ Prathap Gunasekaran - I used left join to display the value
    – GeorgeM
    Mar 29, 2019 at 14:24

1 Answer 1


Try this,

Add a column in sales_order_grid table like you have in sales_order

Then add a sales_order_grid.xml in the below path


add the below code in it

<?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="column_name_in_table">
    <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">Column Name Goes here</item>
            <item name="visible" xsi:type="boolean">false</item>

then add di.xml in the below path


add the below code in it

<?xml version="1.0"?>                                                   
<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" type="Magento\Sales\Model\ResourceModel\Grid">
    <argument name="columns">
        <item name="customer_manager" xsi:type="string">sales_order.column_name_in_table</item>

column_name_in_table is the name of column which you have in sales_order table and make you have same column in sales_order_grid table as well.

NOTE : When you post data into sales_order table next time then it will also be added into sales_order_grid table as then xml will list the column in grid view and you can add filter and sortable option to it.

Run below commands after you made these changes

php bin/magento setup:upgrade
php bin/magento cache:flush

Hope this helps :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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