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
view/adminhtml/uicomponent/sales_order_grid.xml
:
<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>
</item>
</argument>
</column>
</columns>
And when I'm saving a new order I would like to populate the sales_order_grid
so I added this code in
etc/adminhtml/di.xml:
<virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid">
<arguments>
<argument name="columns" xsi:type="array">
<item name="shipping_date" xsi:type="string">sales_order.shipping_date</item>
</argument>
</arguments>
</virtualType>
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 ?