开发者

Magento get session messages

I am trying to access Magento's current session's messages (ones written by addError).

I am doing this from inside of the Cart model.

$smessages = Mage::getSingleton('checkout/session')->getMessages(true);

Returns an array of all messages correctly.

However, when I try to "foreach" through $smessages, I get nothing. The idea is to then use getText() within the loop to get each individual message.

foreach ($smessages as $smessage) {
  Mage::log($sme开发者_运维知识库ssage);
}

What am I doing wrong?


I figured it out!

 $smessages = Mage::getSingleton('checkout/session')->getMessages()->getItems();
 $output = NULL;
 foreach ($smessages as $smessage) {
      $output .= $smessage->getText();
 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜