开发者

Magento get session messages

开发者 https://www.devze.com 2023-03-03 10:20 出处:网络
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.

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

精彩评论

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