I have got currency switch dropdown set up on header.phtml and its working fine and changing the currency correctly but its keep redirecting back to home page every time I switched the currency. How can I prevent it from going back to home page and stay in current page after page reload?

in my browser this url was 302 before I get redirected to home page http://myshop//directory/currency/switch/currency/USD/uenc/aHR0cDovL... 302 moved temporarily

1 Answer 1


Basically,magento is change the currency at Mage_Directory_CurrencyController on switchAction() function.

And using _redirectReferer() is redirect to previous page.

May the REFERER url getRefererUrl() is not working thus magento redirect to home page .

And as send a site url has been send as option url for redirection after currency change thus it redirect to home page.

see Mage_Core_Controller_Varien_Action on function.

 protected function _redirectReferer($defaultUrl=null)

        $refererUrl = $this->_getRefererUrl();
        if (empty($refererUrl)) {
            $refererUrl = empty($defaultUrl) ? Mage::getBaseUrl() : $defaultUrl;

        return $this;


you need check previous page url value by adding code:

    $refererUrl = Mage::helper('core')->urlDecodeAndEscape( $this->getRequest()->getParam('uenc')) ); 

at Mage_Directory_CurrencyController. it should be give you previous page url

  • Yea I am also digging into the core code and saw this but how to replace with $this->_redirectReferer(Mage::getBaseUrl()); to user current url ?
    – zaw
    Jun 24, 2015 at 7:10
  • is there a core magento function that get current url? $currentUrl = Mage::helper('core/url')->getCurrentUrl(); i'm not sure but gonna give this a try
    – zaw
    Jun 24, 2015 at 7:13
  • I am not seeing this code $refererUrl = Mage::helper('core')->urlDecodeAndEscape( $this->getRequest()->getParam('uenc')) ); at Mage_Directory_CurrencyController at app/code/Mage/Directory/controllers/CurrencyController.php
    – zaw
    Jun 24, 2015 at 7:17
  • just add this code and check your refere url is right or wrong
    – Amit Bera
    Jun 24, 2015 at 7:46
  • I found the problem its actually magneto base64_decode returning blank
    – zaw
    Jun 24, 2015 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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