1

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 – Tirth Patel Oct 12 '18 at 9:28
2

Try following way:

VendorName/ModuleName/etc/di.xml


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

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 – Tirth Patel Oct 12 '18 at 9:50
  • just adding this code to di file ..how it works? – Tirth Patel 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 – Tirth Patel 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.