How to Add a Custom Column in Magento 2 Products Grid

How to Add a Custom Column in Magento 2 Products Grid

The default Magento 2 product grid makes it easy to add a column for displaying values for any product attribute. As they are already available under column control of the products grid toolbar. You just need to tick the check/uncheck for that product attribute under Columns control to show/hide values.

However, to add a custom column in Magento 2 product grid that is not a product attribute is not supported by default Magento 2. You need to apply the below solution to add custom columns like stock, quantity, website or any data that is not a product attribute.

More organized the data, easier it will be for the admin to manage the products.

Steps to Add a Custom Column in Magento 2 Products Grid:

  1. Create registration.php file in app\code\[Vendor]\[Namespace]\
  2. Create module.xml file in app\code\[Vendor]\[Namespace]\etc
  3. Create product_listing.xml file in app\code\[Vendor]\[Namespace]\adminhtml\ui_component
  4. Create di.xml file in app\code\[Vendor]\[Namespace]\etc\adminhtml
  5. Create AddCustomField.php file in app\code\[Vendor]\[Namespace]\Ui\DataProvider\Product\

That’s it.

Any doubts on the topic can be mentioned in the Comments section below. I’d be happy to help.

Feel free to share the solution with fellow developers via social media.

Thanks.

Get Weekly Updates

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

Thank you for subscribing.

Something went wrong.

4.1
(based on 8 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.

Leave a reply:

Your email address will not be published.