Skip to content

Instantly share code, notes, and snippets.

@evgv
Last active October 5, 2016 11:26
Show Gist options
  • Save evgv/a6b4a036f5c60e4f80909bd2d309ef45 to your computer and use it in GitHub Desktop.
Save evgv/a6b4a036f5c60e4f80909bd2d309ef45 to your computer and use it in GitHub Desktop.
Magento. Add session messages.

Add session messages.

Notice

  // You can use `core/session`, `customer/session`, `checkout/session`, `adminhtml/session`
  Mage::getSingleton('core/session')->addNotice('Notice Message');

Success

  // You can use `core/session`, `customer/session`, `checkout/session`, `adminhtml/session`
  Mage::getSingleton('core/session')->addSuccess('Success Message');

Warning

  // You can use `core/session`, `customer/session`, `checkout/session`, `adminhtml/session`
  Mage::getSingleton('core/session')->addWarning('Warning Message');

Error

  // You can use `core/session`, `customer/session`, `checkout/session`, `adminhtml/session`
  Mage::getSingleton('core/session')->addError('Error Message');

Get session messages.

In ..app/design/frontend/base/default/template/page/* templates

  <div class="col-main">
    <?php echo $this->getChildHtml('global_messages') ?>
  </div>

and app/design/frontend/base/default/layout/page.xml layout

  <block type="core/messages" name="global_messages" as="global_messages"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment