How to Add Custom Mass Action to Product Grid In Magento 2
Backend grids in Magento 2 make the life of store admins easier!
The edit, delete or update actions can be made directly from the grid. Moreover, Magento 2 offers mass action to perform these actions in bulk.
The default product grid in Magento 2 offers mass actions like:
However, increasing business demands may not be satisfied with these default mass actions. Hence, you may add custom mass action in product grid in Magento 2.
For example, using a mass action, the admin can update the price or quantity of products in bulk, or generate barcode for products.
Develop your custom code for any such actions with the help of the below solution:
Method to Add Custom Mass Action in Product Grid in Magento 2
What you have to do is.
Create product_listing.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 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<?xml version="1.0" Programmatic Solutionencoding="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"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="component" xsi:type="string">Magento_Ui/js/grid/tree-massactions</item> </item> </argument> <action name="barcode"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="type" xsi:type="string">massoperation</item> <item name="label" xsi:type="string" translate="true">Custom Mass Action</item> <item name="url" xsi:type="url" path="extension/controller/massaction"/> <item name="confirm" xsi:type="array"> <item name="title" xsi:type="string" translate="true">Custom Mass Action</item> <item name="message" xsi:type="string" translate="true">Are you sure want to Perform Custom Action For selected items? </item> </item> </item> </argument> </action> </massaction> <paging name="listing_paging"/> </listingToolbar> </listing> |
After executing this code, you manage to add custom mass action in the product grid.
If you have queries regarding this post, feel free to ask in the Comment section below.
I would be happy to answer your question.
Do consider sharing this post to Magento Community via social media.
Thank you.
Related Posts:
Prev
How to Move Magento 2 from Localhost to Server
How to Add Custom Mass Action in Customer Grid in Magento 2
Next