Magento – Set and unset system messages

You can use this code to clear error message 

Mage::getSingleton('core/session')->getMessages(true); // The true is for clearing them after loading them

You can use the following code show the Magento message

//A Success Message
Mage::getSingleton('core/session')->addSuccess("Some success message");

//A Error Message
Mage::getSingleton('core/session')->addError("Some error message");

//A Info Message (See link below)
Mage::getSingleton('core/session')->addNotice("This is just a FYI message...");

//These lines are required to get it to work
session_write_close(); //THIS LINE IS VERY IMPORTANT!

Revisions

No comments yet.

Leave a Reply