cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement mass action to a product grid column in magento 2

SOLVED

How to implement mass action to a product grid column in magento 2

H guys, can any one help me.How to implement mass action to a product grid column in magento 2 ?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to implement mass action to a product grid column in magento 2

@bharath553 


Massaction is already implemented in Product grid if you want to add one more action in the list you can create app/code/Vendor/ModuleName/view/adminhtml/ui_component/product_listing.xml in your module add below code in it:

<?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" component="Magento_Ui/js/grid/tree-massactions">
            <action name="status">
                <settings>
                    <type>status</type>
                    <label translate="true">Change status</label>
                    <actions>
                        <action name="0">
                            <type>enable</type>
                            <label translate="true">Enable in All Store Views</label>
                            <url path="catalog/product/massStatus">
                                <param name="status">1</param>
                            </url>
                        </action>
                        <action name="1">
                            <type>disable</type>
                            <label translate="true">Disable in All Store Views</label>
                            <url path="catalog/product/massStatus">
                                <param name="status">2</param>
                            </url>
                        </action>
                    </actions>
                </settings>
            </action>
        </massaction>
        <paging name="listing_paging"/>
    </listingToolbar>
</listing>

You can add your action instead of <action name="status">.

Problem solved? Please give 'Kudos' and accept 'Answer as Solution'.

View solution in original post

1 REPLY 1

Re: How to implement mass action to a product grid column in magento 2

@bharath553 


Massaction is already implemented in Product grid if you want to add one more action in the list you can create app/code/Vendor/ModuleName/view/adminhtml/ui_component/product_listing.xml in your module add below code in it:

<?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" component="Magento_Ui/js/grid/tree-massactions">
            <action name="status">
                <settings>
                    <type>status</type>
                    <label translate="true">Change status</label>
                    <actions>
                        <action name="0">
                            <type>enable</type>
                            <label translate="true">Enable in All Store Views</label>
                            <url path="catalog/product/massStatus">
                                <param name="status">1</param>
                            </url>
                        </action>
                        <action name="1">
                            <type>disable</type>
                            <label translate="true">Disable in All Store Views</label>
                            <url path="catalog/product/massStatus">
                                <param name="status">2</param>
                            </url>
                        </action>
                    </actions>
                </settings>
            </action>
        </massaction>
        <paging name="listing_paging"/>
    </listingToolbar>
</listing>

You can add your action instead of <action name="status">.

Problem solved? Please give 'Kudos' and accept 'Answer as Solution'.