I added a new attribute on order entity :

$salesSetup->addAttribute(Order::ENTITY, "shipping_date", [
    'type'     => "date",
    'label'    => "Shipping date",
    'input'    => "text",
    'user_defined' => true,
    'required' => false,
    'visible' => true

and display it on the sales order grid



<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="shipping_date">
        <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">Shipping Date</item>

And when I'm saving a new order I would like to populate the sales_order_grid so I added this code in


<virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid">
        <argument name="columns" xsi:type="array">
            <item name="shipping_date" xsi:type="string">sales_order.shipping_date</item>

The issue is when I'm saving the order it creates a blank line in sales_order_grid table with only the shipping date filled, all other fields are NULL, where is my mistake ?

  • I followed this way, but all the value are updating to the sales_order_grid table except the custom column value. is there any other code is missing? – senthil Oct 10 '18 at 10:40
  • Also when i add the above virtualtype my page will be blank – senthil Oct 10 '18 at 10:56

I think it's because you forget to add the type on your virtualType in di.xml
Update your virtualType like this :

<virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid" type="Magento\Sales\Model\ResourceModel\Grid">
        <argument name="columns" xsi:type="array">
            <item name="shipping_date" xsi:type="string">sales_order.shipping_date</item>

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.