• Magento, Web Dev

    How to redirect Magento newsletter url

    Posted on June 13th, 2010

    Written by CJ

    Tags

    How to redirect Magento newsletter subscriber to a landing page url

    This article is in response to unanswered Magento Post, found at http://www.magentocommerce.com/boards/viewthread/178109/

    Magento does a good job with their newsletter infrastructure, but just like their web app, it does require you to fine tune it to your specifications. One such fine tuning is the way the newsletter handles it’s subscribers, once they subscribe. Ideally, when the customer subscribes you would want them to keep shopping and not to read a form about newsletter policy.

    1. A pop up would do the trick, but what if they have pop ups from being displayed.
    2. A simple note saying, Thank you for your subscription. For more info on our Newsletter Policy please click here. Magento already has this feature but without the link being dispalyed.
    3. Or redirect to a CMS page which shows special discounted products viewed only by new subscribers. Here you can place your newsletter policy in short format, so it’s not obtrusive, but yet is available if the subscriber wants to read.

    Either of these methods require hacking in Magento Core files. I’ll show you Method 2 and 3.

    Method 2.

    A simple note saying, Thank you for your subscription. For more info on our Newsletter Policy please click here.

    Log into Magento Admin>CMS>Manage Pages>Add New Page

    Create a Newsletter Policy CMS page, i.e. newsletter-promotions

    Open SubscriberController.php file located in:
    MagentoStore\App\Code\Core\Mage\Newsletter\controllers\

    Change

    $session->addSuccess($this->__('Thank you for your subscription'));

    To
    $session->addSuccess($this->__('Thank you for your subscription. For more info on our Newsletter Policy, please click <a href="newsletter-promotions" target="_self">here</a>.'));

    It would be a good idea to also do the same for; Please enter a valid email address; Confirmation request has been sent; and There was a problem with the subscription, messages.

    Method 3.

    Redirect to a special page of discounted products vieable only by subscribers, which contains the newsletter policy.

    Magento Admin>Catalog>Manage Products>Add New Product
    Create new special discounted products, with Visibilty attribute set to, Nowhere. Make a note of the product ID.

    Magento Admin>CMS>Manage Pages>Add New Page
    Create a Newsletter Policy CMS page, i.e. newsletter-policy-and-promotions. In this page you can add your special products you created for your new subscribers. (This is not covered in the scope of this, How To)

    Change at approx line 65:

    $this->_redirectReferer();

    To
    $this->_redirectUrl(Mage::getBaseUrl().'newsletter-policy-and-promotions');

    Change at approx line 92:

    $this->_redirectUrl(Mage::getBaseUrl());

    To
    $this->_redirectUrl(Mage::getBaseUrl().'newsletter-policy-and-promotions');

    Now the subscriber will automatically be redirected to your new page, and the, "Thank you for your subscription" message will still be displayed.

    Hope this helps you.

    This entry was posted on Sunday, June 13th, 2010 at 1:26 pm and is filed under Magento, Web Dev. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.
  • 8 Comments

    Take a look at some of the responses we've had to this article.

    1. " How to redirect Magento newsletter url "

      Nithin Chacko Ninan
      Posted on October 28th

      Thanks a lot, it works in magento enterprise 1.9.

      $this->_redirectReferer();

      to

      $this->_redirectUrl(Mage::getBaseUrl().’newsletter-policy-and-promotions’);

      also

      $this->_redirectUrl(Mage::getBaseUrl().’newsletter-policy-and-promotions’);

      $this->_redirectUrl(Mage::getBaseUrl());

      to
      $this->_redirectUrl(Mage::getBaseUrl());

    2. " How to redirect Magento newsletter url "

      Nithin Chacko Ninan
      Posted on October 28th

      Thanks a lot, it works in magento enterprise 1.9.

      $this->_redirectReferer();

      to

      $this->_redirectUrl(Mage::getBaseUrl().’newsletter-policy-and-promotions’);

      also

      $this->_redirectUrl(Mage::getBaseUrl());

      to
      $this->_redirectUrl(Mage::getBaseUrl().’newsletter-policy-and-promotions’);

    3. " How to redirect Magento newsletter url "

      Posted on November 3rd

      Custom Magento Themes Based on an Existing Design.If you already have a starting point for your Magento theme design and need it implemented or improved on then we’re here for you.

    4. " How to redirect Magento newsletter url "

      Posted on November 27th

      thankyou for the read I loved it.
      I really like the layout of your site.
      I have bookmarked. thanks

    5. " How to redirect Magento newsletter url "

      Shaun E
      Posted on December 6th

      Great post. I’ll add one more option, which is somewhat similar to Method 3 above. You can redirect to a CMS page (or another page outside magento) by using Magento events. There are two things you have to do.

      First define the event in your module’s config.xml file. Something like this…

      singleton
      yourmodule/observer
      redirectNewsletterSuccess

      singleton
      yourmodule/observer
      redirectNewsletterConfirm

      Then create a new class in app/code/local/Yournamespace/Yourmodule/Model/Observer.php…
      class Yournamespace_Yourmodule_Model_Observer {

      public function redirectNewsletterSuccess ($observer){
      Mage::app()->getResponse()->setRedirect(Mage::getBaseUrl().”newsletter-thanks.html”);
      }

      public function redirectNewsletterConfirm($observer) {
      Mage::app()->getResponse()->setRedirect(Mage::getBaseUrl().”newsletter-confirmed.html”);
      }
      }

      (This assumes that you have two CMS pages with ids “newsletter-success.html” and “newsletter-confirmed.html”)

      The main advantage of this over Method 3 is that it doesn’t require a controller override, and is potentially more safe for upgrades. One downside is that you might not get the special error/success messages displayed on the cms, depending on your theme.

    6. " How to redirect Magento newsletter url "

      Shaun E
      Posted on December 6th

      Woops looks like Wordpress stripped out a bunch of the xml tags I pasted in… I’ll try one more time.
      <frontend>
      <events>
      <controller_action_postdispatch_newsletter_subscriber_new>
      <observers>
      <newsletter_subscribe_observer>
      <type>singleton</type>
      <class>yourmodule/observer</class>
      <method>redirectNewsletterSuccess</method>
      </newsletter_subscribe_observer>
      </observers>
      </controller_action_postdispatch_newsletter_subscriber_new>
      <controller_action_postdispatch_newsletter_subscriber_confirm>
      <observers>
      <newsletter_subscribe_observer>
      <type>singleton</type>
      <class>yourmodule/observer</class>
      <method>redirectNewsletterConfirm</method>
      </newsletter_subscribe_observer>
      </observers>
      </controller_action_postdispatch_newsletter_subscriber_confirm>
      </events>
      </frontend>

    7. " How to redirect Magento newsletter url "

      Posted on February 3rd

      These are great tips. Find your post very informative. Thanks a lot!

    8. " How to redirect Magento newsletter url "

      Posted on May 5th

      I got it worked with this very simple solution, you just have to change the confirmation message:

      $status = Mage::getModel(’newsletter/subscriber’)->subscribe($email);
      if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
      $session->addSuccess($this->__(’Confirmation request has been sent.’));
      }
      else {
      $session->addSuccess($this->__(’Thank you for your subscription.’));
      }

      TO

      $status = Mage::getModel(’newsletter/subscriber’)->subscribe($email);
      if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
      $session->addSuccess($this->__(’location = “/newsletter-subscribe(or whatever page you wanted”;’));
      }
      else {
      $session->addSuccess($this->__(’location = “/newsletter-subscribe”;’));
      }

  • Post a Comment

    Let us know what you thought.

  • Name:

    Email:

    Website:

    Message: