I have created custom column in sales_order table in Magento 2. At the time placing order values is saved in that column. Now I want to this column to be available for filter option.
Magento 2 Order Grid – How to Add Custom Column to Filter Option
columncustom-optionsmagento2order-grid
Best Answer
For the performance, the Order Admin Grid will load the values from
sales_order_grid
. So, we need to add more columns to this table.app/code/Vendor/SalesOrder/Setup/UpgradeSchema.php
Declare this column to ui grid:
app/code/Vendor/SalesOrder/view/adminhtml/ui_component/sales_order_grid.xml
Populate the custom field in
sales_order_grid
. See more here:vendor/magento/module-sales/Model/ResourceModel/Grid.php::refresh()
app/code/Vendor/SalesOrder/etc/di.xml
Remember to create the
registration.php
andmodule.xml
.