Get magento default session messages

Hi friends, I spend much time on this , You can render magento default session message.You can also render these  message and call them by Ajax.

<?php 
 /*Brings checkout sessions message*/
$messages=Mage::getSingleton("checkout/session")->getMessages();
 /*Get layout and render default message*/
echo this->getLayout()->createBlock("core/messages")->setMessages($messages)->getGroupedHtml();

Note: If you want another session's message then  modify your Singleton:
$messages=Mage::getSingleton("customer/session")->getMessages();
or
$messages=Mage::getSingleton("core/session")->getMessages();
or
$messages=Mage::getSingleton("checkout/session")->getMessages();
?>
All done Enjoy!! =========

Comments

Popular posts from this blog

Sort Products by popularity count in Magento

Safe name of a file by php