{"id":335083,"date":"2022-05-15T07:49:20","date_gmt":"2022-05-15T07:49:20","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=335083"},"modified":"2026-02-11T13:23:40","modified_gmt":"2026-02-11T13:23:40","slug":"add-custom-column-filter-in-order-grid-collection-in-magento-2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/","title":{"rendered":"Add Custom Column Filter in Order Grid Collection in Magento 2"},"content":{"rendered":"\n<p>We\u2019ll explore how to add a custom column\u2019s filter to Magento 2 order grid collection, enabling more precise filtering based on fields you\u2019ve added to your order tables.<\/p>\n\n\n\n<p>For example, a <em>custom_column<\/em> field is created in the <em>sales_order<\/em> and <em>sales_order_grid<\/em> record tables in the database and we want to add the filter for the <em>custom_column<\/em> field when fetching the collection for the sales order grid. <\/p>\n\n\n\n<p>Then, to achieve this functionality, please follow the below steps:<\/p>\n\n\n\n<p><strong>Step1.<\/strong> Create<em> di.xml<\/em> file inside the <em>app\/code\/Vendor\/Module\/etc\/ <\/em>directory. Create preference class <strong>Vendor\\Module\\Model\\ResourceModel\\Order\\Grid\\Collection<\/strong> for <strong>Magento\\Sales\\Model\\ResourceModel\\Order\\Grid\\Collection <\/strong>class in di.xml file as following.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:ObjectManager\/etc\/config.xsd&quot;&gt;\n    &lt;preference for=&quot;Magento\\Sales\\Model\\ResourceModel\\Order\\Grid\\Collection&quot; type=&quot;Vendor\\Module\\Model\\ResourceModel\\Order\\Grid\\Collection&quot;\/&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<p><strong>Step2. <\/strong>Create <em>Collection.php<\/em> file inside the <em>app\/code\/Vendor\/Module\/Model\/ResourceModel\/Order\/Grid\/Collection<\/em> directory. In this file, we have overrided the <em>_initSelect() <\/em>method to add filter for our <em>custom_column<\/em> field.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Vendor\\Module\\Model\\ResourceModel\\Order\\Grid;\n\nuse Magento\\Framework\\App\\ObjectManager;\nuse Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface as FetchStrategy;\nuse Magento\\Framework\\Data\\Collection\\EntityFactoryInterface as EntityFactory;\nuse Magento\\Framework\\Event\\ManagerInterface as EventManager;\nuse Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface;\nuse Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\SearchResult;\nuse Magento\\Sales\\Model\\ResourceModel\\Order;\nuse Psr\\Log\\LoggerInterface as Logger;\n\n\/**\n * Order grid collection based on tenant\n *\/\nclass Collection extends \\Magento\\Sales\\Model\\ResourceModel\\Order\\Grid\\Collection\n{\n    \/**\n     * @var TimezoneInterface\n     *\/\n    private $timeZone;\n\n    \/**\n     * Initialize dependencies.\n     *\n     * @param EntityFactory $entityFactory\n     * @param Logger $logger\n     * @param FetchStrategy $fetchStrategy\n     * @param EventManager $eventManager\n     * @param string $mainTable\n     * @param string $resourceModel\n     * @param TimezoneInterface|null $timeZone\n     *\/\n    public function __construct(\n        EntityFactory $entityFactory,\n        Logger $logger,\n        FetchStrategy $fetchStrategy,\n        EventManager $eventManager,\n        $mainTable = &#039;sales_order_grid&#039;,\n        $resourceModel = Order::class,\n        TimezoneInterface $timeZone = null\n    ) {\n        parent::__construct(\n            $entityFactory,\n            $logger,\n            $fetchStrategy,\n            $eventManager,\n            $mainTable,\n            $resourceModel,\n            $timeZone\n        );\n        $this-&gt;timeZone = $timeZone ?: ObjectManager::getInstance()\n            -&gt;get(TimezoneInterface::class);\n    }\n\n    \/**\n     * @inheritdoc\n     *\/\n    protected function _initSelect()\n    {\n        parent::_initSelect();\n        \n        \/\/filter for custom_column field\n        $value = 10;\n        $this-&gt;addFieldToFilter(&quot;custom_column&quot;, $value);\n\n        return $this;\n    }\n}<\/pre>\n\n\n\n<p>If you want to display the custom column in the sales order grid. Then refer to the following blog link:<br><a href=\"https:\/\/webkul.com\/blog\/add-custom-columns-to-order-grid-in-admin-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/webkul.com\/blog\/add-custom-columns-to-order-grid-in-admin-magento-2\/<\/a><\/p>\n\n\n\n<p>Hope this will be helpful.<br>Thanks \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We\u2019ll explore how to add a custom column\u2019s filter to Magento 2 order grid collection, enabling more precise filtering based on fields you\u2019ve added to your order tables. For example, a custom_column field is created in the sales_order and sales_order_grid record tables in the database and we want to add the filter for the custom_column <a href=\"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":249,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9121],"tags":[12750,12751,12753,5604,12754],"class_list":["post-335083","post","type-post","status-publish","format-standard","hentry","category-magento-2","tag-add-custom-column-filter-in-order-grid-collection-in-magento-2","tag-add-custom-columns-to-order-grid-in-admin-magento-2","tag-add-custom-field-filter-in-order-grid-collection","tag-custom-filter","tag-order-grid-collection"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Add custom column filter in order grid collection in Magento 2<\/title>\n<meta name=\"description\" content=\"This guide walks you through overriding the default order grid collection and implementing a custom field filter so your Magento 2 admin can filter orders by your new column.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Add custom column filter in order grid collection in Magento 2\" \/>\n<meta property=\"og:description\" content=\"This guide walks you through overriding the default order grid collection and implementing a custom field filter so your Magento 2 admin can filter orders by your new column.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-15T07:49:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-11T13:23:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Khushboo Sahu\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Khushboo Sahu\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/\"},\"author\":{\"name\":\"Khushboo Sahu\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/f94b8f53397bf85810761d76c98fadca\"},\"headline\":\"Add Custom Column Filter in Order Grid Collection in Magento 2\",\"datePublished\":\"2022-05-15T07:49:20+00:00\",\"dateModified\":\"2026-02-11T13:23:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/\"},\"wordCount\":195,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"keywords\":[\"Add custom column filter in order grid collection in Magento 2\",\"Add custom columns to Order Grid in Admin Magento 2\",\"add custom field filter in order grid collection\",\"Custom Filter\",\"order grid collection\"],\"articleSection\":[\"Magento 2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/\",\"url\":\"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/\",\"name\":\"Add custom column filter in order grid collection in Magento 2\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2022-05-15T07:49:20+00:00\",\"dateModified\":\"2026-02-11T13:23:40+00:00\",\"description\":\"This guide walks you through overriding the default order grid collection and implementing a custom field filter so your Magento 2 admin can filter orders by your new column.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Add Custom Column Filter in Order Grid Collection in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/f94b8f53397bf85810761d76c98fadca\",\"name\":\"Khushboo Sahu\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cabac965df656d114e6bf340df07518c990eda03bb09265dbd5c17f1097adaae?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cabac965df656d114e6bf340df07518c990eda03bb09265dbd5c17f1097adaae?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"caption\":\"Khushboo Sahu\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/khushboo-sahu062\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Add custom column filter in order grid collection in Magento 2","description":"This guide walks you through overriding the default order grid collection and implementing a custom field filter so your Magento 2 admin can filter orders by your new column.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"Add custom column filter in order grid collection in Magento 2","og_description":"This guide walks you through overriding the default order grid collection and implementing a custom field filter so your Magento 2 admin can filter orders by your new column.","og_url":"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2022-05-15T07:49:20+00:00","article_modified_time":"2026-02-11T13:23:40+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Khushboo Sahu","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Khushboo Sahu","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/"},"author":{"name":"Khushboo Sahu","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/f94b8f53397bf85810761d76c98fadca"},"headline":"Add Custom Column Filter in Order Grid Collection in Magento 2","datePublished":"2022-05-15T07:49:20+00:00","dateModified":"2026-02-11T13:23:40+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/"},"wordCount":195,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"keywords":["Add custom column filter in order grid collection in Magento 2","Add custom columns to Order Grid in Admin Magento 2","add custom field filter in order grid collection","Custom Filter","order grid collection"],"articleSection":["Magento 2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/","url":"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/","name":"Add custom column filter in order grid collection in Magento 2","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2022-05-15T07:49:20+00:00","dateModified":"2026-02-11T13:23:40+00:00","description":"This guide walks you through overriding the default order grid collection and implementing a custom field filter so your Magento 2 admin can filter orders by your new column.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/add-custom-column-filter-in-order-grid-collection-in-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Add Custom Column Filter in Order Grid Collection in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/f94b8f53397bf85810761d76c98fadca","name":"Khushboo Sahu","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cabac965df656d114e6bf340df07518c990eda03bb09265dbd5c17f1097adaae?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cabac965df656d114e6bf340df07518c990eda03bb09265dbd5c17f1097adaae?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","caption":"Khushboo Sahu"},"url":"https:\/\/webkul.com\/blog\/author\/khushboo-sahu062\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/335083","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/249"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=335083"}],"version-history":[{"count":4,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/335083\/revisions"}],"predecessor-version":[{"id":525992,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/335083\/revisions\/525992"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=335083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=335083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=335083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}