Now, You are thinking how we will overwrite the grid.php in Magento 2. Because some module has grid.php and some has not.
Now We are adding the one massaction in Sales_order Grid at admin side which has no grid.php for order.
1. Create the file sales_order_grid.xml in the path app\code\[Vendor Name]\[Module Name]\view\adminhtml\ui_component
2. Write the following code in the file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?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="sendemail"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="type" xsi:type="string">sendemail</item> <item name="label" xsi:type="string" translate="true">Send Email</item> <item name="url" xsi:type="url" path="sales/order/sendemail"/> </item> </argument> </action> </massaction> </container> </listing> |
So first the container tag correlate to the top part of the grid using the listing_top name
Then the massaction tag matches the mass action block.
The action tag is we will defined our new action item, we need to give it a name (same as the item id in Magento 1).
The argument tag is array of argument and we can see from the xsi:type attribute.
we need add item configuration array. In this item array tag, we add three item tags:
type: which matches the action tag name and give the unique code
label: It is the text which displayed in the massaction dropdown
url: which is the URL It will be redirected to when select this item
Now Refresh the order grid and check in Massaction.