Search code examples
phpxmlmagentoobservers

why adding observer not working with me in magento


thanks for reading, I'm trying to add new fields to newsletter in magento. Made my search and found this answer which I think it's the most right one. but when I added my observer, magento is not saving the new emails and some times the message

There was a problem with the subscription

appears. here is the code: config.xml(were my module is My_test in local):

           <newsletter_subscriber_save_before>
                <observers>
                    <class>test/newsletter_observer</class>
                    <method>add</method>
                </observers>
            </newsletter_subscriber_save_before>

and in file app/code/local/My/Test/Model/Newsletter/Observer.php :

class My_Test_Model_Newsletter_Observer{
   public function add($observer){
        // no thing here for now ..
    }
}

can any one help?? thanx in advance.


Solution

  • @allGood, i see that you have missing events name

     <newsletter_subscriber_save_before>
          <observers>
          <my_newsletter>
            <class>test/newsletter_observer</class>
           <method>add</method>
         </my_newsletter>
        </observers>
      </newsletter_subscriber_save_before>
    

    more details:http://blog.chapagain.com.np/magento-event-observer-with-save-before-and-save-after/