1

Is there an event in Magento 1.9.x for Newsletter Subscription from the Profile page?

How do I find out when a user updates their newsletter subscription preference from this page?

I tried controller_action_predispatch_newsletter_manage_save and newsletter_subscriber_save_after events. Although not getting any subcriber data through either of the following:

$event = $observer->getEvent();
 $isSubscribed = $event->getRequest()->getParam('is_subscribed');

or

$subscriber = $observer->getEvent()->getSubscriber();
$data = $subscriber->getData();

1 Answer 1

3

Try listening to the model_save_after event with something like this (pseudocode):

public function checkSubscriptionPreference(Varien_Event_Observer $observer)
{
    $model = $observer->getObject();
    if (!$model instanceof Mage_Newsletter_Model_Subscriber) {
        return;
    }

    if ($model->isSubscribed()) {
        // your logic here
    }
}

There are other similar events that you could use depending on what you need, such as model_save_before, model_load_before, etc.

7
  • 1
    Source: nicksays.co.uk/magento-events-cheat-sheet-1-9 - see Mage/Core/Model/Abstract.php:390 for the code that fires the event. Apr 27, 2017 at 15:40
  • Are there other activities as well that throw the same event? I am looking for something specific to Newsletter subscription.
    – Guruji
    Apr 27, 2017 at 18:03
  • Never mind.. got your point. let me try this out.
    – Guruji
    Apr 27, 2017 at 18:10
  • 1
    I went ahead with this implementation itself. Working well for me. Thanks for your help!
    – Guruji
    May 5, 2017 at 16:23
  • 1
    There's a better observer to use, 'newsletter_subscriber_save_after', which is specific for that model, that way it doesn't fire on every observer save
    – eddhall
    Mar 9, 2018 at 16:08

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.