I have a save address function in my checkout and after the validation in the controller takes place if there is an error the following gets rendered.
if(isset($result['error']) && $result['error']){
foreach($result['message'] as $msg){
Mage::getSingleton('checkout/session')->addError($msg);
$this->_message[] = $msg;
}
return $this->_redirectUrl($this->_getRefererUrl());
}
The referrer is a method belonging to the same controller so I assumed setting the variable $this->_message
would mean I can access the message from the referrer method but it seems as though the class gets re-instantiated because if I do a var_dump($this->_message);
in the referrer method it is null. I know there are messages getting set because if I don't redirect back to the referrer Mage::getSingleton('checkout/session')->addError($msg);
works – aka it displays which fields need to be filled in on the form.
How can I make the messages available to the referrer method?
Best Answer
I've added them to an array and stored this in the session like so
But using session variables isn't my desired solution so any other answers still very welcome!