How do I retrieve a success message in Magento?
Array
(
[core] => Array
(
[_session_validator_data] => Array
(
[remote_addr] => 192.168.151.102
[http_via] =>
[http_x_forwarded_for] =>
[http_user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4
)
[session_hosts] => Array
(
[technova2] => 1
)
[messages] => Mage_Core_Model_Message_Collection Object
(
[_messages:protected] => Array
(
)
[_lastAddedMessage:protected] => Mage_Core_Model_Message_Success Object
(
[_type:protected] => success
[_code:protected] => Your review has been accepted for moderation
[_class:protected] =>
[_method:protected] =>
[_identifier:protected] =>
[_isSticky:protected] =>
)
)
[just_voted_poll] =>
[visitor_data] => Array
(
[] =>
[server_addr] => -1062692990
[remote_addr] => -1062693018
[http_secure] =>
[http_host] => technova2
[http_user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4
[http_accept_language] => en-US,en;q=0.8
[http_accept_charset] => ISO-8859-1,utf-8;q=0.7,*;q=0.3
[request_uri] => /~rahuls/sextoys/index.php/review/product/list/id/169/
[session_id] => 21bq2vtkup5m1gtghknlu1tit42c6dup
[http_referer] => http://technova2/~rahuls/sextoys/index.php/review/product/list/id/169/
[first_visit_at] => 2010-06-16 05:49:56
[is_new_visitor] =>
[last_visit_at] => 2010-06-16 06:00:00
[visitor_id] => 935
[last_url_id] => 23558
)
[last_url] => http://technova2/~rahuls/sextoys/index.php/review/product/list/id/169/
)
)
After posting the review I want to display the message: "Your review has been accepted for moderation". It appears in the $_SESSION array, but how do I fetch it? Please help. Thanks in advance.
You will need to do three things: Call an appropriate method with the right parameters; Add your messages to Magento\Framework\View\Element\Message\MessageConfigurationsPool ; Create a template responsible for message rendering.
Method 3: Edit app/bootstrap. htaccess file which is the preferred way to enable error display on your Magento site, you can also edit the PHP file. To edit the file, follow the steps below: Firstly, access your Magento's root directory. Then, open the file app/bootstrap.
It is a combination of all your answers. This works for me from just about any block:
//A Success Message
Mage::getSingleton('checkout/session')->addSuccess("Your cart has been updated successfully!");
//A Error Message
Mage::getSingleton('checkout/session')->addError("Your cart has been updated successfully!");
//A Info Message (See link below)
Mage::getSingleton('checkout/session')->addNotice("This is just a FYI message...");
//These two lines are required to get it to work
session_write_close(); //THIS LINE IS VERY IMPORTANT!
$this->_redirect('checkout/cart');
Credit due to:
http://www.magentocommerce.com/boards/viewthread/40324/ (Where I posted the answer)
and
http://www.deepcodeonline.com/blog/magento/how-to-display-error-success-and-notice-messages-in-magento/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With