cancel
Showing results for 
Search instead for 
Did you mean: 

Observer mag1 to mag2

SOLVED

Observer mag1 to mag2

Hello everyone,

 

I am writing the Magento2 version of a module written for Magento 1.9. How can I "translate" this observer code?

 

        if ($idBlockObserver=="sales_order_grid" ) {
            $block = $observer->getEvent()
                ->getBlock()
                ->getMassactionBlock();
            
            if ($block) {
                $block->addItem('custom_export', array(
                    'label'=> Mage::helper('custom_export')->__('Export It'),
                    'url'  => Mage::getUrl('module_name', array('_secure'=>true)),
                ));
            }
        }
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Observer mag1 to mag2

Magento 2 using the ui component for grid. for adding the mass action to grid foolow below insturction.

Duplicate Grid Component File

In  your module create the duplicate gird file name for example order grid use sales_order_grid.xml so we create same name file our module view/adminhtml/ui_component folder we create the following file:

QaisarSatti/HelloWorld/view/adminhtml/ui_component/sales_order_grid.xml
 
 
 Add Mass Action

<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="nameofaction">
            	<argument name="data" xsi:type="array">
                	<item name="config" xsi:type="array">
                    	<item name="type" xsi:type="string">testing</item>
                    	<item name="label" xsi:type="string" translate="true">My Label</item>
                    	<item name="url" xsi:type="url" path="adminrouter/filder/controllername"/>
                	</item>
            	</argument>
        	</action>
	</massaction>
</container>
</listing>
Follow tutorial for more detail
Find helpful ? Consider Giving Kudos to this post.
Problem solved? Click Accept as Solution!"
Qaisar Satti

View solution in original post

1 REPLY 1

Re: Observer mag1 to mag2

Magento 2 using the ui component for grid. for adding the mass action to grid foolow below insturction.

Duplicate Grid Component File

In  your module create the duplicate gird file name for example order grid use sales_order_grid.xml so we create same name file our module view/adminhtml/ui_component folder we create the following file:

QaisarSatti/HelloWorld/view/adminhtml/ui_component/sales_order_grid.xml
 
 
 Add Mass Action

<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="nameofaction">
            	<argument name="data" xsi:type="array">
                	<item name="config" xsi:type="array">
                    	<item name="type" xsi:type="string">testing</item>
                    	<item name="label" xsi:type="string" translate="true">My Label</item>
                    	<item name="url" xsi:type="url" path="adminrouter/filder/controllername"/>
                	</item>
            	</argument>
        	</action>
	</massaction>
</container>
</listing>
Follow tutorial for more detail
Find helpful ? Consider Giving Kudos to this post.
Problem solved? Click Accept as Solution!"
Qaisar Satti