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)), )); } }
Solved! Go to Solution.
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:
<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
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:
<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