1

I'm using in some Controller Code like:

Mage::getSingleton('core/session')->addError('Did you forget your password?');

$this->_redirect( 'customer/account/forgotpassword' );

I don't understand what's the difference between _redirect and _redirectError. Hope someone can give me a hint.

$this->_redirectError( 'customer/account/forgotpassword' );

1 Answer 1

2

If you take a look at the function in Mage_Core_Controller_Varien_Action

const PARAM_NAME_ERROR_URL          = 'error_url';
[...]
/**
 * Redirect to error page
 *
 * @param string $defaultUrl
 * @return  Mage_Core_Controller_Varien_Action
 */
protected function _redirectError($defaultUrl)
{
        $errorUrl = $this->getRequest()->getParam(self::PARAM_NAME_ERROR_URL);
        if (empty($errorUrl)) {
            $errorUrl = $defaultUrl;
        }
        if (!$this->_isUrlInternal($errorUrl)) {
            $errorUrl = Mage::app()->getStore()->getBaseUrl();
        }
        $this->getResponse()->setRedirect($errorUrl);
        return $this;
}

Magento only check if there is an error_url parameter in the current request. If there is one it redirect to this URL. If there is no error_url parameter it redirect to the default URL, here the function parameter.
On another side the _redirect() function make a "simple" redirect to the provided URL.
Note that also have a _redirectSuccess() function based on the same logic as _redirectError()

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.