Add success or error message using magento session
Error message
Set error message for front page.
Set error message for admin page.
$message = $this->__('Got an error');
Mage::getSingleton('core/session')->addError($message);
$message = $this->__('Got an error');
Mage::getSingleton('adminhtml/session')->addError($message);
Success message
Set success message for front page.
Set success message for admin page.
$message = $this->__('Got an error');
Mage::getSingleton('core/session')->addSuccess($message);
If you are unable to view the error/success message, add the function
$message = $this->__('Got an error');
Mage::getSingleton('adminhtml/session')->addSuccess($message);
session_write_close()
after setting message. I got such problem while using with redirect method. Nitroware solved this problem.Now the new snippet will look like below,
$message = $this->__('Got an error');
Mage::getSingleton('adminhtml/session')->addError($message);
session_write_close();
Notice Message
By this way we can show notice message by using addNotice().
$message = $this->__('Please note this modification');
Mage::getSingleton('core/session')->addNotice($message);
Hello Karthik,
ReplyDeleteThanks for the useful article.
How can I display an error message when the user enters wrong login info (frontend) - when trying to login to the site? (where do I add the error message code)
Thanks again