i want to add custome data when data adds in sales_order automatically it copied into sales_order_grid i have same name column in both table

  • custom data or customer data?
    – Amit Bera
    Oct 12 '18 at 9:26
  • custom field data Oct 12 '18 at 9:28

Try following way:


<?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" xsi:type="array">
                <item name="custom_column_name" xsi:type="string">sales_order.custom_column_name</item>

Clear cache and have to di compile.

  • if want to implement virtual column on grid column?
    – Amit Bera
    Oct 12 '18 at 9:40
  • not virtual i want to put data in sales_order_grid table as data enters in sales_order programatically Oct 12 '18 at 9:50
  • just adding this code to di file ..how it works? Oct 12 '18 at 9:50
  • as i place order i add extra data to sales_order table i just want to add those data to sales_order_grid automatically Oct 12 '18 at 9:59
  • Now you just added above di.xml, then automatically save your sales_order table column data to sales_order_grid column.
    – Sohel Rana
    Oct 12 '18 at 10:00

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.