How to show custom action in Newsletter Subscribers
-
14-04-2021 - |
Question
I am trying to create custom action for newsletter subscribers, however I am unable to see the action as you can see in the image below:
I have created a file named newsletter_subscriber_block.xml
, as I suppose this is the file which is going to show the custom action, I found it here. However, I also then created a file newsletter_subscriber_grid.xml
, still I don't see the action in the dropdown menu.
I didn't get any error though, during the module installation.
UPDATEL: My code in XML file is below.
<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">
<alertaction name="listing_action">
<action name="email_to_customer">
<settings>
<url path="alert/email/Send"/>
<type>email_to_customer</type>
<label translate="true">Email</label>
</settings>
</action>
</alertaction>
</listingToolbar>
</listing>
Solution
your custom layout newsletter_subscriber_block.xml should look like below:
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="adminhtml.newslettrer.subscriber.grid.massaction">
<arguments>
<argument name="options" xsi:type="array">
<item name="email_to_customer" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Email</item>
<item name="url" xsi:type="string">alert/email/send</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
then, your custom massaction will appear. After this, you will need to implement a backend controller and adjust the route in the above snippet