display message
$this->_initLayoutMessages('catalog/session');
$this->_initLayoutMessages('checkout/session');
protected function _initLayoutMessages($messagesStorage)
{
if (!is_array($messagesStorage)) {
$messagesStorage = array($messagesStorage);
}
foreach ($messagesStorage as $storageName) {
$storage = Mage::getSingleton($storageName);
if ($storage) {
$block = $this->getLayout()->getMessagesBlock();
$block->addMessages($storage->getMessages(true));
$block->setEscapeMessageFlag($storage->getEscapeMessages(true));
}
else {
Mage::throwException(
Mage::helper('core')->__('Invalid messages storage "%s" for layout messages initialization', (string) $storageName)
);
}
}
return $this;
}
///////////////////////////////////////////////////////////////////
public function addSuccess($message)
{
$this->addMessage(Mage::getSingleton('core/message')->success($message));
return $this;
}
public function getLayout()
{
return Mage::getSingleton('core/layout');
}
$block = Mage::getSingleton('core/layout')->getMessagesBlock(); or
$block = $this->getLayout()->getMessagesBlock();
$block->addSuccess('message to addd');
$block->addNotice('message to addd');
$block->addWarning('message to addd');