{"id":1406,"date":"2020-11-17T10:50:45","date_gmt":"2020-11-17T10:50:45","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/add-custom-mass-action-in-product-grid-in-magento-2\/"},"modified":"2025-07-17T10:23:16","modified_gmt":"2025-07-17T04:53:16","slug":"add-custom-mass-action-in-product-grid-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/add-custom-mass-action-in-product-grid-in-magento-2\/","title":{"rendered":"How to Add Custom Mass Action to Product Grid In Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Backend grids in\u00a0Magento 2\u00a0make the life of store admins easier!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The default product grid in Magento 2 offers mass actions like:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/11\/Default-Product-Grid-1024x498.png\" alt=\"Default Product Grid in Magento 2\" class=\"wp-image-11553\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">However, increasing business demands may not be satisfied with these default mass actions. Hence, you may&nbsp;<em><strong>add custom mass action in product grid in Magento 2<\/strong><\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, using a mass action, the admin can update the price or quantity of products in bulk, or generate barcode for products.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Develop your custom code for any such actions with the help of the below solution:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Add Custom Mass Action in Product Grid in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">What you have to do is.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create&nbsp;<strong>product_listing.xml<\/strong>&nbsp;file at&nbsp;<strong><strong>app\\code\\Vendor\\Extension\\view\\adminhtml\\ui_component\\<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\" Programmatic Solutionencoding=\"UTF-8\"?>\n&lt;listing xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n         xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Ui:etc\/ui_configuration.xsd\">\n    &lt;listingToolbar name=\"listing_top\">\n        &lt;massaction name=\"listing_massaction\">\n            &lt;argument name=\"data\" xsi:type=\"array\">\n                &lt;item name=\"config\" xsi:type=\"array\">\n                    &lt;item name=\"component\" xsi:type=\"string\">Magento_Ui\/js\/grid\/tree-massactions&lt;\/item>\n                &lt;\/item>\n            &lt;\/argument>\n            &lt;action name=\"barcode\">\n                &lt;argument name=\"data\" xsi:type=\"array\">\n                    &lt;item name=\"config\" xsi:type=\"array\">\n                        &lt;item name=\"type\" xsi:type=\"string\">massoperation&lt;\/item>\n                        &lt;item name=\"label\" xsi:type=\"string\" translate=\"true\">Custom Mass Action&lt;\/item>\n                        &lt;item name=\"url\" xsi:type=\"url\" path=\"extension\/controller\/massaction\"\/>\n                        &lt;item name=\"confirm\" xsi:type=\"array\">\n                            &lt;item name=\"title\" xsi:type=\"string\" translate=\"true\">Custom Mass Action&lt;\/item>\n                            &lt;item name=\"message\" xsi:type=\"string\" translate=\"true\">Are you sure want to Perform Custom\n                                Action For selected items?\n                            &lt;\/item>\n                        &lt;\/item>\n                    &lt;\/item>\n                &lt;\/argument>\n            &lt;\/action>\n        &lt;\/massaction>\n        &lt;paging name=\"listing_paging\"\/>\n    &lt;\/listingToolbar>\n&lt;\/listing><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After executing this code, you manage to add custom mass action in the product grid.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/11\/Annotation-on-2020-11-05-at-13-21-13-1024x456.png\" alt=\"Add Custom Mass Action in the Product Grid in Magento 2\" class=\"wp-image-11507\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Do consider sharing this post to Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Related Posts:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/meetanshi.com\/blog\/add-custom-mass-action-in-order-grid-in-magento-2\/\">How to Add Mass Action in Order Grid in Magento 2<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/meetanshi.com\/blog\/configure-magento-2-product-listing\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Configure Magento 2 Product Listing<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Backend grids in\u00a0Magento 2\u00a0make the life of store admins easier! The edit, delete or update actions can be made directly from the grid. Moreover, Magento&#8230;<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1406","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1406"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1406\/revisions"}],"predecessor-version":[{"id":13933,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1406\/revisions\/13933"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}