2

I used below code in breadcrumb template to display the notice and messages

<div class="GlobalerrorBox">
    <div class="container ">
        <div class="message fL">
            <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
        </div>
    <div class="fR"><i class="fa fa-times"></i></div>
    </div>
</div>

It is working for voucher code messages and add to cart messages but Newsletter error message not displayed in this template.

I need to display newsletter messages in same breadcrumb template

1 Answer 1

2

I wrote a blog article about this: http://blog.fabian-blechschmidt.de/messages-in-magento-only-loaded-by-default-from-core-session/

The problem is, magento only loads core/session by default:

<block type="core/messages" name="global_messages" as="global_messages"/>
<block type="core/messages" name="messages" as="messages"/>

loads only the messages of core/session:

app/code/core/Mage/Core/Block/Messages.php:79
public function _prepareLayout()
{
    $this->addMessages(Mage::getSingleton('core/session')->getMessages(true));
    parent::_prepareLayout();
}

You need to check, where this message comes from, I would assume newsletter/session, but it is: Mage::getSingleton('customer/session')

To fix this, you can copy the messages over with an observer:

$customerSession = Mage::getSingleton('customer/session');
$coreSession = Mage::getSingleton('core/session');
foreach ($customerSession->getMessages()->getItems() as $message) {
    $coreSession->addMessage($message);
}
$customerSession->getMessages(true);

Make sure this is done AFTER $action->loadLayoutUpdates() / $this->loadLayoutUpdates()

More on this in the blogpost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.