Skip to main content
Blog General

Magento 2 – How to Add a New Column in Admin Grid?

Thanga Durai
October 12, 2016 |

In the USA, tax rates vary widely among most states and some localities. In order to add tax rates for different cities, some of our clients had a pressing need to add a city column to the ‘Tax Manager’ admin grid. To solve this, we were working on developing an extension in Magento 2. But adding the column was not a straight-forward affair. We faced some challenges in overriding the admin grid in Magento 2. We resolved this and as usual, wanted to share our solution so that the community benefits as well.

Step by step procedure : Magento 2 – How to Add a New Column in Admin Grid?

Step 1:

Module Registration

Create a custom module based on the Magento 2 structure in the folder app/code

File Path : Magento-CE-2.0.8/app/code/DCKAP/Tax/registration.php

Step 2:

Module Configuration

Create a module.xml file in the below path to define your Magento 2 extension

File Path: Magento-CE-2.0.8/app/code/DCKAP/Tax/etc/module.xml

Step 3:

Override Grid

Locate the core module admin grid xml file path. Create the same folder path under custom module.

File Path :  Magento-CE-2.0.8/app/code/DCKAP/Tax/view/adminhtml/layout/tax_rate_block.xml

Step 4:

Create custom field

Create a new field ‘City’ and define this under the reference block it needs to be shown.

After completing the above steps run the below command.

After running the above command, clear all the Magento cache and check if the extension has been successfully installed in Magento 2 admin.

Once the extension has been installed you will be able to view the custom field in admin as shown in the screen shot below.

add column magento 2

 

Hope the blog was useful. Let us know if you have any comments or queries. We will be happy to hear from you.

Here’s how to add a new column to admin grid in Magento 2. Learn some of the intricacies in Magento 2 from certified Magento developers who has developed numerous websites.

Thanga Durai

Thangadurai is one of our senior software engineers and is Magento Developer Plus Certified. A sincere worker, he is part of one of the most successful and long-running projects in DCKAP. A fitness enthusiast, he tones his body when not fine tuning his code. Listening to music and playing Table Tennis are his other hobbies.

More posts by Thanga Durai