Showing results for 
Search instead for 
Did you mean: 

Observer mag1 to mag2


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()
            if ($block) {
                $block->addItem('custom_export', array(
                    'label'=> Mage::helper('custom_export')->__('Export It'),
                    'url'  => Mage::getUrl('module_name', array('_secure'=>true)),

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:

 Add Mass Action

<listing xmlns:xsi="" 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"/>
Follow tutorial for more detail
Find helpful ? Consider Giving Kudos to this post.
Problem solved? Click Accept as Solution!"
Qaisar Satti