How to Add Custom Mass Action in Order Grid in Magento 2
The admin grids in Magento 2 backend are an easy way to manage data, sort, edit, filter, or delete it.
The admin grids are well-equipped with mass actions such as Cancel, Print, Delete, etc.
The default Magento 2 order grid mass action looks something like this:
However, increasing business innovations and urgency to complete the task lists have compelled the developers to customize the admin grids and add mass actions to get things done quickly.
Talking about the standard Magento 2 order grid, it’s mass actions is pretty much enough for basic order management tasks. But we are not satisfied with the basics, are we!
Therefore, I’ve come up with a programmatic solution to add custom mass action in order grid in Magento 2.
Adding custom mass action in Magento 2 order grid will allow the store admins to:
- Process orders efficiently
- Convenience in order management
- More work, less time
- Less dependency on the developers
Using Magento 2 UI components, one can add new mass action to the existing order grid in Magento 2 as shown below:
Method to Add Custom Mass Action in Order Grid in Magento 2:
Create sales_order_grid.xml file at app\code\Vendor\Extension\view\adminhtml\ui_component\
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?xml version="1.0" encoding="UTF-8"?> <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> <listingToolbar name="listing_top"> <massaction name="listing_massaction"> <action name="mass_order_custom_action"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="type" xsi:type="string">order_custom_action</item> <item name="label" xsi:type="string" translate="true">Custom Mass Action</item> <item name="url" xsi:type="url" path="fourth/index/"/> </item> </argument> </action> </massaction> </listingToolbar> </listing> |
That’s it.
It is an example to add “Print Order Preparation” mass action in the order grid as shown below:
You can refer the same for adding custom mass actions to order grid as per your Magento 2 project requirements!
Meanwhile, you can use the Comments section below if you have any doubts. I’d be happy to help you out.
Also, do share this useful solution with Magento 2 store admins and developers via social media.
Thank you.
Jignesh Parmar
An expert in his field, Jignesh is the team leader at Meetanshi and a certified Magento developer. His passion for Magento has inspired others in the team too. Apart from work, he is a cricket lover.
Prev
The Ultimate Guide To Start Online Business From Home
Must Read for Merchants – Magento 2 Migration Loan by PayPal’s LoanBuilder
Next