I will like to show message from controller to view in magento. In controller I have
$arrError=Mage::getModel('advert/advert')->isValid(array('step1','step2'));
if (!empty($arrError)) {
$strReturnPath = $arrError['return_path'];
unset($arrError['return_path']);
foreach ($arrError as $strError) {
Mage::getSingleton('customer/session')->addError( $strError );
//var_dump($strError);
}
$this->_redirect($strReturnPath);
}
$this->loadLayout();
$this->_initLayoutMessages('customer/session');
$this->renderLayout();
And in view I have
<div id="messages_product_error_view">
<?php
Mage::app()->getLayout()->getMessagesBlock()->setMessages(Mage::getSingleton('customer/session')->getMessages(true));
echo Mage::app()->getLayout()->getMessagesBlock()->toHtml();
?>
</div>
In controller when I do a var_dump I can see the error messages. With redirect, the page does redirect to the view page. However, in the div I expect the message to be shown. ANd it is not showing Please please please help?