1

I am using this to generate URL for unsubscribe in email template

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

This only generates this link: http://www.sitename.com/index.php/newsletter/subscriber/unsubscribe/ without any code and id in URL

The method in app\code\core\Mage\Newsletter\Helper\Data.php looks like this

public function getUnsubscribeUrl($subscriber)
    {
        return Mage::getModel('core/url')
            ->setStore($subscriber->getStoreId())
            ->getUrl('newsletter/subscriber/unsubscribe', array(
                'id'     => $subscriber->getId(),
                'code'   => $subscriber->getCode(),
                '_nosid' => true
            ));

   }

I have tested it many time using test newsletter option How can I fix this issue ?

1

Your call is subscriber.getUnsubscriptionLink(), but the function is getUnsubscribeUrl() (LINK vs. URL)

1

I know I am late here but still I want to share solution here.

I am using Magento 1.9. To add newsletter unsubscribe link in newsletter template here are following steps:

  1. Override the core file

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

by copy in local directory

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

  1. Open in editor to edit the code and search the function sendConfirmationSuccessEmail() replace the code
$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 this

$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())
);
  1. and place this code in email template where you want to use unsubscribe link:

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

That's it!

Hope this helps someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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