Skip to main content
3 of 5
added 1795 characters in body
PЯINCƎ
  • 11.7k
  • 3
  • 26
  • 82

config.xml update this :

<events>
    <mi_productautosynchronization_notifications_before>
        <observers>
            <mi_productautosynchronization_observer>
                <type>singleton</type>
                <class>MI_ProductAutoSynchronization_Model_Observer</class>
                <method>checkMessages</method>
            </mi_productautosynchronization_observer>
        </observers>
    </mi_productautosynchronization_notifications_before>
</events>

to :

<events>
    <mi_productautosynchronization_notifications_before>
        <observers>
            <mi_productautosynchronization_observer>
                <type>singleton</type>
                <class>MI_ProductAutoSynchronization_Model_Observer</class>
                <method>checkMessages</method>
            </mi_productautosynchronization_observer>
            <mi_productautosynchronization_test_observer>
                <type>singleton</type>
                <class>MI_ProductAutoSynchronization_Model_Observer</class>
                <method>test</method>
            </mi_productautosynchronization_test_observer>
        </observers>
    </mi_productautosynchronization_notifications_before>
</events>

Observer.php

<?php
class MI_ProductAutoSynchronization_Model_Observer extends Varien_Event_Observer {

public function test($observer) {
      $controllerAction = $observer->getEvent()->getControllerAction();
      Mage::log("TEST success", null, "dev.log"); // for your logs
      Mage::getSingleton('adminhtml/session')->addError(Mage::helper('MI_ProductAutoSynchronization')->__('Error sending Email'));
      Mage::app()->getResponse()->setRedirect($controllerAction->getUrl('*/sales_order/')); //the controller where you want to redirect
      Mage::app()->getResponse()->sendResponse();
      exit ;
}

public function checkMessages($observer) {
      Mage::log("notification success", null, "dev.log");
      $notifications = Mage::getSingleton('mi_productautosynchronization/notification');
      $notifications->addMessage("I was sent by mi_productautosynchronization");
      return $observer;
}
}
PЯINCƎ
  • 11.7k
  • 3
  • 26
  • 82