Hello Magento Friends 👋,

In this article, I am going to explain Magento 2: How to Add Custom Mass Action in Product Grid. Look at our previously published blog, Magento 2: How to Redirect on Checkout Page After Add to Cart.

Magento 2 comes with UI components that allow adding columns, filters, and mass actions. In Magento 2 there are some mass actions available in the product admin grid. You need to extend the product_listing.xml file, to add custom mass action in the product grid as shown below. By this, custom mass action will be displayed in the dropdown of Action.

Let’s start with the steps to Add Custom Mass Action in the Product grid in Magento 2 🚀

Steps to Add Custom Mass Action in Product Grid in Magento 2:

Step 1: Go to the following path: 

app\code\Vendor\Extension\view\adminhtml\ui_component\product_listing.xml

And add the below code:

Step 2: After that, create MassSalable.php file at the below path:

app\code\Vendor\Extension\Controller\Adminhtml\Index\MassSalable.php

Finally, add the code as mentioned underneath:

Output: In this way, you can set value enable/disable of “Sale” attribute value in the product grid and will get the result as shown in the below image.

custom mass action

Conclusion:

Accordingly, you can add custom mass action in the product grid in Magento 2. As per your requirement, you can add any custom mass action. Similarly, you can even Add Custom Mass Action to the Admin Grid in Magento 2.

For any doubts and questions, kindly mention in the comment part. Keep sharing and stay connected!

Happy Coding 😊

Click to rate this post!
[Total: 9 Average: 4.6]