2

We have a custom written Magento 2 module that adds an action to the order overview dropdown. dropdown Now we have ran into an issue where it would work on 2.0.x but not 2.1.x and up.

After a bit of research it is caused by Magento changing an xml node from container to listingToolbar.

Now my question is, how do we make our module compatible with both 2.0.x and 2.1.x? Adding both; container and listingToolbar will break the massaction dropdown.

magento 2.0.x version:

<?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">                      
<container name="listing_top">                                                                                                                                      
    <massaction name="listing_massaction">                                                                                                                              
        <action name="new_action">                                                                                                                                      
            <argument name="data" xsi:type="array">                                                                                                                      
                <item name="config" xsi:type="array">                                                                                                                    
                    <item name="type" xsi:type="string">action_name</item>                                                                                              
                    <item name="label" xsi:type="string" translate="true">Action Name Text Here</item>                                                                    
                    <item name="url" xsi:type="url" path="vendor_module/action"/>                                                                      
                </item>                                                                                                                                                  
            </argument>                                                                                                                                                  
        </action>                                                                                                                                                        
    </massaction>                                                                                                                                                        
</container>                                                                                                                                                        

magento 2.1.x version:

<?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="new_action">                                                                                                                                      
            <argument name="data" xsi:type="array">                                                                                                                      
                <item name="config" xsi:type="array">                                                                                                                    
                    <item name="type" xsi:type="string">action_name</item>                                                                                              
                    <item name="label" xsi:type="string" translate="true">Action Name Text Here</item>                                                                    
                    <item name="url" xsi:type="url" path="vendor_module/action"/>                                                                      
                </item>                                                                                                                                                  
            </argument>                                                                                                                                                  
        </action>                                                                                                                                                        
    </massaction>                                                                                                                                                        
</listingToolbar>                                                                                                                                                        

Is there a way to do this without rewriting some core parts of Magento?
Elsner gave a way to do it this link and there are more examples where you rewrite big parts of Magento but isn't there a more "easy" way?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.