Evrig

Hey there! Making sure we send out newsletters is super important for any online store like ours. It helps our brand become more well-known, and it keeps our customers interested in what we have to offer!

When you’re sending emails, it’s important to make sure your users have a good experience. Email service providers require you to add a link that lets users unsubscribe if they’re not interested. This way, users can easily opt out of your emails, keeping their experience smooth and hassle-free.

Sometimes, if you own a Magento 2 store, dealing with a non-functional Newsletter Unsubscribe Link can be quite challenging and might even upset your shoppers. In this blog, I’ll guide you through creating a custom module to add a working newsletter unsubscribe link smoothly and effortlessly.

Fixing: Non-Functional Magento Newsletter Unsubscribe Link

To add the unsubscribe link, you need to modify two essential classes in Magento:

  • MagentoNewsletterModelTemplate
  • MagentoNewsletterModelQueue

By enhancing these two classes, you can apply the needed adjustments to your newsletter.

Now, let’s closely examine each class.

Template.php

In the Template.php file, broaden the Magento NewsletterModelTemplate class.

Within this function, insert the unsubscription link by configuring the template text and incorporating the variable {{var subscriber.unsubscriptionLink}}.

  if (!$this->getData('template_text') && !$this->getId()) {
            $this->setData(
                'template_text',
                __(
                    'Follow this link to unsubscribe ' .
                    '{{var subscriber.unsubscriptionLink}}' .
                    ''
                )
            );
        }

This variable guarantees that every email contains a distinct unsubscription link personalized for each subscriber receiving your emails.

Let’s proceed to the next step.

Queue.php

In the Queue.php file, expand the MagentoNewsletterModelQueue class within the method. Here, you’ll be incorporating the link into your email template.

 $item->setData('unsubscriptionLink', $item->getUnsubscriptionLink()); 

This code guarantees the link is added to every email you send, ensuring its effective functionality.

And that’s all there is to it!

By following these steps, you can send a newsletter with an unsubscription link, preventing unexpected errors when shoppers attempt to opt out. I believe this solution will assist you in resolving the issue. I encourage you to give it a try, and if you encounter any challenges during the implementation, feel free to reach out in the comments section. I’m here to assist you!

If you found this solution helpful for the issue of Magento newsletter unsubscribe link not working, I encourage you to share it on your social media platforms and with any Magento communities you are a part of. Your support can help others facing similar challenges.
Contact Us