Reputation: 8607
I've created an observer and I need to populate the messages_product_view div on the product page when a specific event happens. How can I go about populating this div? Below is a screenshot of the area that I need to populate.
Upvotes: 0
Views: 2174
Reputation: 1095
See the Magento Session models i.e. core/session, customer/session etc.
To add a message you can use for example:
Mage::getSingleton('core/session')->addSuccess($message); // Add green success message
Mage::getSingleton('core/session')->addError($message); // Add red error message
Mage::getSingleton('core/session')->addNotice($message); // Add yellow notice message
Template files have a call to the following which renders the session messages. Look for this:
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
Messages can also be retrieved manually like so:
$messages = Mage::getSingleton('core/session')->getMessages(true);
foreach($messages->getItems() as $message)
{
$message->getText();
//...
}
Upvotes: 3