How to Add Multi Select Filter in Magento 2 Admin Grid

How to Add Multi Select Filter in Magento 2 Admin Grid

Have you ever needed a Magento 2 admin grid that is filterable by more column’s values, i.e. something from multiselect drop-down?

For example, you want to export customers with 3 different groups and you have to select a group thrice and export the data for all the 3 one by one. However, if you want to filter all 3 of them together, you cannot perform a single action as the default Magento 2 allows applying only one filter at a time.

If the business requirement demands to apply a mass action on products satisfying more than one condition, the solution below can be helpful.

Implement the below code to add multi select filter in Magento 2 admin grid as shown in the figure below:

How to Add Multi Select Filter in Magento 2 Admin Grid

Steps to Add Multi-Select Filter in Magento 2 Admin Grid:

  1. Add this code into ui_component’s grid xml file:
    for example : [Vendor]\[Module]\view\adminhtml\ui_component\my_first_grid.xml
  2. Create Status.php file at path [Vendor]\[Module]\Model\ProductImage\Status.php

That’s it.

Any doubts on the topic will be entertained in the Comments section below. I’d be happy to solve it.

Do share the solution with fellow developers via social media.

 

5
(based on 2 Reviews)

Sanjay is a co-founder at Meetanshi. He is a certified Magento developer who loves creating Magento E-commerce solutions. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a Reply