Magento Global Messages : what they are and do?

Thursday, 15. December 2011

If you have been working with Magento templates, I am sure you have come across the global messages instructions/references and perhaps wondered what they are and/or what do they do?

You will see them mostly on the layout phtml file i.e 1column.phtml, 2columns-left.phtml etc referenced are

echo $this->getChildHtml('global_messages');

Well, by default Magento stores all the messages (success/errors/warnings) in a specific session array. So whenever a page is being rendered, Magento will reference to this session array to see if there is any sort of message that needs to be displayed for this particular page.

If any exist, Magento will get it shown on the this loading page and critically enough, it then removes/clears the messages from its array.

So if you have ever wondered, how come the references to global_messages are there but you don’t see anything on the front-end, well, its simply because there is no message to show in the array session! And when you see messages such as your products has been added successfully to the shopping cart, The configuration has been saved etc they are global messages!

Leave a Reply

You must be logged in to post a comment.