0

I want to add unsubscribe link in the custom email template. I am using code:

<a href="{{var subscriber.getUnsubscriptionLink()}}"><strong>Unsubscribe</strong></a>

But it is not working, can anybody help to do this?

1
  • to use unsubscribe variable in custom email template you have to set it first from your code to send email
    – Piyush
    Oct 30, 2017 at 10:46

2 Answers 2

2

You need to create custom variable and use in the custom email template. for example:

$unsubscribeUrl = Mage::getModel('newsletter/subscriber')->loadByEmail($email)->getUnsubscriptionLink();
$vars = array('quote' => $quote, 'url' => $url, 'customunsubscribeurl' => $unsubscribeUrl);

Now, You can use "customunsubscribeurl" in custom email template.

0

Try this code :

<a href="{{var subscriber.getUnsubscriptionLink()}}">
{{var subscriber.getUnsubscriptionLink()}}
</a>

Or you can try this also :

=> Copy the core file

/app/code/core/Mage/Newsletter/Model/Subscriber.php

=> add in your local directory

/app/code/local/Mage/Newsletter/Model/Subscriber.php

replace code in endConfirmationSuccessEmail()

$email->sendTransactional(
    Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE),
    Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY),
    $this->getEmail(),
    $this->getName(),
    array('subscriber'=>$this)
);

with

$email->sendTransactional(
    Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE),
    Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY),
    $this->getEmail(),
    $this->getName(),
    array('subscriber'=>$this, 'unsubscribe' =>$this->getUnsubscriptionLink())
);

right this code where you want to add unsubscribe link :

<a href="{{var unsubscribe}}">Unsubscribe here</a>

It may be useful for you :)

4
  • Any other solution becouse I have tried this. Oct 30, 2017 at 10:35
  • No sir, I have no other solution. I checked it and its working. Oct 30, 2017 at 10:40
  • Can I use "unsubscribe" var outside newsletter email template Oct 30, 2017 at 10:44
  • Nop. It's not possible. Oct 30, 2017 at 10:47

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.