0

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:

enter image description here

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>

1 Answer 1

1

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

7
  • thanks for the reply, I pasted above code, but it doesn't show, I still have same options as shown in the picture in my question. also how do I mention the action and alertaction as is in my code, that code works in Sales and Customer page
    – nix
    Aug 2, 2020 at 4:49
  • Maybe post a link to your module? Aug 2, 2020 at 5:16
  • I am using github.com/magevision/magento2-mass-email-customers module, and it works for customer & sales, now I am trying to edit it to add newsletter subscriber functionality, I created a new directory layout under admin/view, and pasted new file newsletter_subscriber_block.xml with your code. but doesn't show.
    – nix
    Aug 2, 2020 at 5:22
  • I was able to add it, I had a typo in newslettrer*, instead i had written newsletter. I have a question, Is it necessary for it to be just like this > <argument name="options" xsi:type="array"> or I can change name argument to other e.g. email_to_customer?
    – nix
    Aug 2, 2020 at 5:41
  • I am getting error however > LocalizedException): An item needs to be selected. Select and try again.
    – nix
    Aug 2, 2020 at 5:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.