Skip to main content
added 389 characters in body
Source Link
PЯINCƎ
  • 11.7k
  • 3
  • 26
  • 82

How the session messages work ?

addSuccess, addError, addNotice, addWarning.

The message that you give for those methods are stored in the session. when a page is viewed, Magento checks in the session for messages. If there are any, they are displayed and removed from the session, all the messages are saved to the session and are shown the next time.

How the session messages work ?

addSuccess, addError, addNotice, addWarning.

The message that you give for those methods are stored in the session. when a page is viewed, Magento checks in the session for messages. If there are any, they are displayed and removed from the session, all the messages are saved to the session and are shown the next time.

added 258 characters in body
Source Link
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) {
      /*Display the message in the next refresh*/
      Mage::getSingleton('adminhtml/session')->addError(Mage::helper('MI_ProductAutoSynchronization')->__('Error sending Email'));

      // Refresh and display
      // $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;
}
}

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;
}
}

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) {
      /*Display the message in the next refresh*/
      Mage::getSingleton('adminhtml/session')->addError(Mage::helper('MI_ProductAutoSynchronization')->__('Error sending Email'));

      // Refresh and display
      // $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;
}
}
added 1795 characters in body
Source Link
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;
}
}
public function test() {
      $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 ;
}

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;
}
}
deleted 45 characters in body
Source Link
PЯINCƎ
  • 11.7k
  • 3
  • 26
  • 82
Loading
Source Link
PЯINCƎ
  • 11.7k
  • 3
  • 26
  • 82
Loading