{"id":1178,"date":"2020-08-15T03:30:05","date_gmt":"2020-08-15T03:30:05","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/08\/15\/include-discount-column-in-admin-order-grid-in-magento-2\/"},"modified":"2025-05-22T12:01:42","modified_gmt":"2025-05-22T06:31:42","slug":"include-discount-column-in-admin-order-grid-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/include-discount-column-in-admin-order-grid-in-magento-2\/","title":{"rendered":"How to Include Discount Column in Admin Order Grid without Adding Field in sales_order_grid table in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-admin\/stores-sales\/guide-overview\" target=\"_blank\" rel=\"noreferrer noopener\">Order grid in Magento 2<\/a>&nbsp;displays the order data.&nbsp;The order grid lists the order data like order ID, purchase date, order amount, customer name who placed the order, grand total, subtotal, payment method, etc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The order data in grid format makes it easy for the admin to process every order, manage the delivery, and smoothly fulfil each order.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The default sales order grid in the backend facilitates the option to show the selected columns among the default options.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, owing to modern business requirements, the admin may require to&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/add-custom-column-in-order-grid-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">add a custom column in order grid in Magento 2<\/a>&nbsp;for better order processing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Faster and smoother order processing gives a delightful shopping experience. It also reduces the admin\u2019s workload.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One such instance is to add the custom discount column in admin order grid. The admin can easily manage the discounts assigned with each order, analyze the benefits of offering discounts, etc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The programmatic method to&nbsp;add discount column in admin order grid without adding field in sales_order_grid table in Magento 2&nbsp;is easy, as shown below:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Include Discount Column in Admin Order Grid Without Adding Field in sales_order_grid Table in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Create,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em><strong>app\/code\/Meetanshi\/DiscountColumn\/Model\/ResourceModel\/Order\/Grid\/Collection.php<\/strong><\/em><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace Meetanshi\\DiscountColumn\\Model\\ResourceModel\\Order\\Grid;\n\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\\Sales\\Model\\ResourceModel\\Order\\Grid\\Collection as OriginalCollection;\nuse Psr\\Log\\LoggerInterface as Logger;\n\n\/**\n * Order grid extended collection\n *\/\nclass Collection extends OriginalCollection\n{\n    protected $helper;\n\n    public function __construct(\n        EntityFactory $entityFactory,\n        Logger $logger,\n        FetchStrategy $fetchStrategy,\n        EventManager $eventManager,\n        $mainTable = 'sales_order_grid',\n        $resourceModel = \\Magento\\Sales\\Model\\ResourceModel\\Order::class\n    )\n    {\n        parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);\n    }\n\n    protected function _renderFiltersBefore()\n    {\n        $joinTable = $this->getTable('sales_order');\n        $this->getSelect()->joinLeft($joinTable, 'main_table.entity_id = sales_order.entity_id', ['tax_amount', 'discount_amount']);\n        parent::_renderFiltersBefore();\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Create,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em><strong>\/app\/code\/Meetanshi\/DiscountColumn\/etc\/di.xml<\/strong><\/em><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager\/etc\/config.xsd\">\n    &lt;type name=\"Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\CollectionFactory\">\n        &lt;arguments>\n            &lt;argument name=\"collections\" xsi:type=\"array\">\n                &lt;item name=\"sales_order_grid_data_source\" xsi:type=\"string\">Meetanshi\\DiscountColumn\\Model\\ResourceModel\\Order\\Grid\\Collection&lt;\/item>\n            &lt;\/argument>\n        &lt;\/arguments>\n    &lt;\/type>\n    &lt;type name=\"Meetanshi\\DiscountColumn\\Model\\ResourceModel\\Order\\Grid\\Collection\">\n        &lt;arguments>\n            &lt;argument name=\"mainTable\" xsi:type=\"string\">sales_order_grid&lt;\/argument>\n            &lt;argument name=\"resourceModel\" xsi:type=\"string\">Magento\\Sales\\Model\\ResourceModel\\Order&lt;\/argument>\n        &lt;\/arguments>\n    &lt;\/type>\n&lt;\/config><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3. Create,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em><strong>\/app\/code\/Meetanshi\/DiscountColumn\/etc\/module.xml<\/strong><\/em><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n        xsi:noNamespaceSchemaLocation=\"urn:magento:framework:Module\/etc\/module.xsd\">\n    &lt;module name=\"Meetanshi_DiscountColumn\" setup_version=\"1.0.0\"\/>\n&lt;\/config><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">4. Create,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em><strong>\/app\/code\/Meetanshi\/DiscountColumn\/view\/adminhtml\/ui_component\/sales_order_grid.xml<\/strong><\/em><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?>\n&lt;listing xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Ui:etc\/ui_configuration.xsd\">\n    &lt;columns name=\"sales_order_columns\">\n        &lt;column name=\"tax_amount\" class=\"Magento\\Sales\\Ui\\Component\\Listing\\Column\\PurchasedPrice\">\n            &lt;argument name=\"data\" xsi:type=\"array\">\n                &lt;item name=\"config\" xsi:type=\"array\">\n                    &lt;item name=\"filter\" xsi:type=\"string\">textRange&lt;\/item>\n                    &lt;item name=\"label\" xsi:type=\"string\" translate=\"true\">Tax&lt;\/item>\n                &lt;\/item>\n            &lt;\/argument>\n        &lt;\/column>\n        &lt;column name=\"discount_amount\" class=\"Magento\\Sales\\Ui\\Component\\Listing\\Column\\PurchasedPrice\">\n            &lt;argument name=\"data\" xsi:type=\"array\">\n                &lt;item name=\"config\" xsi:type=\"array\">\n                    &lt;item name=\"filter\" xsi:type=\"string\">textRange&lt;\/item>\n                    &lt;item name=\"label\" xsi:type=\"string\" translate=\"true\">Discount&lt;\/item>\n                &lt;\/item>\n            &lt;\/argument>\n        &lt;\/column>\n    &lt;\/columns>\n&lt;\/listing><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">5. Create,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em><strong>app\/code\/Meetanshi\/DiscountColumn\/registration.php\/<\/strong><\/em><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nuse \\Magento\\Framework\\Component\\ComponentRegistrar;\n\nComponentRegistrar::register(ComponentRegistrar::MODULE, 'Meetanshi_DiscountColumn', __DIR__);<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can&nbsp;<a href=\"https:\/\/github.com\/MeetanshiInc\/Include-Discount-Column-in-Admin-Order-Grid-in-Magento-2\" target=\"_blank\" rel=\"noreferrer noopener\">download the extension from our Github<\/a>&nbsp;or implement the steps as below:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once done, you can see the discount column in order grid:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/08\/Include-Discount-Column-in-Admin-Order-Grid-Without-Adding-Field-in-sales_order_grid-Table-in-Magento-2.png\" alt=\"Discount Column in Admin Order Grid in Magento 2\" class=\"wp-image-10075\" style=\"width:840px;height:auto\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Also, do share the post with the Magento community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Order grid in Magento 2&nbsp;displays the order data.&nbsp;The order grid lists the order data like order ID, purchase date, order amount, customer name who placed&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1178","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1178"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1178\/revisions"}],"predecessor-version":[{"id":14740,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1178\/revisions\/14740"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}