How to Include Discount Column in Admin Order Grid without Adding Field in sales_order_grid table in Magento 2

How to Include Discount Column in Admin Order Grid without Adding Field in sales_order_grid table in Magento 2 4

Order grid in Magento 2 displays the order data. 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.

The order data in grid format makes it easy for the admin to process every order, manage the delivery, and smoothly fulfil each order.

The default sales order grid in the backend facilitates the option to show the selected columns among the default options.

However, owing to modern business requirements, the admin may require to add a custom column in order grid in Magento 2 for better order processing.

Faster and smoother order processing gives a delightful shopping experience. It also reduces the admin’s workload.

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.

The programmatic method to add discount column in admin order grid without adding field in sales_order_grid table in Magento 2 is easy, as shown below:

Method to Include Discount Column in Admin Order Grid Without Adding Field in sales_order_grid Table in Magento 2:

  1. Create app/code/Meetanshi/DiscountColumn/Model/ResourceModel/Order/Grid/Collection.php
  2. Create /app/code/Meetanshi/DiscountColumn/etc/di.xml
  3. Create /app/code/Meetanshi/DiscountColumn/etc/module.xml
  4. Create /app/code/Meetanshi/DiscountColumn/view/adminhtml/ui_component/sales_order_grid.xml
  5. Create app/code/Meetanshi/DiscountColumn/registration.php/

You can download the extension from our Github or implement the steps as below:

That’s it.

Once done, you can see the discount column in order grid:

Discount Column in Admin Order Grid in Magento 2

Any doubts about the solution can be mentioned in the Comments section below. I’ll be happy to help.

Also, do share the post with the Magento community via social media.

Thank you.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

4.9
(based on 17 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

2 comments On How to Include Discount Column in Admin Order Grid without Adding Field in sales_order_grid table in Magento 2

  • I am getting Notice: Undefined index: tax_amount in /var/www/staging/app/code/Magento/Sales/Ui/Component/Listing/Column/PurchasedPrice.php on line 68
    error on magento 2 order grid list.
    Can you please let me know how to fix this issue?

Leave a reply:

Your email address will not be published.