Magento2 I have added custom column in sales_order. I am updating its value via CRON but how can I use same value in sales_order_grid

Below code is use to update sales_order

 $order = $this->orderRepository->get($order->getId()); //1 is your order ID

Please guide to update grid value as well

  • did you use extension attribute concept for saving this value or directly save the value like that ? Commented Feb 28 at 12:08

1 Answer 1


add the same column to your sales_order_grid table and then add this code in di.xml file

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

here shippingaccntno is a custom field added in sales_order and sales_order grid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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