2

As many of you know when switching currency in MAGENTO store, it does not reflect in URL's.

Let say your BASE store currency is in CANADIAN DOLLARS, when sending links by Email to customers in EUROPE, the page they will open will show CAD (Canadian dollar) prices rather than EURO. They have to manually switch currency in the top right corner of the website.

What to add at the end of all links so the prices are shown in EURO ? I need an ending like: ?_currency=EURO

www.exmaple.com/sport-equipment/soccerball/?_currency=EURO

  • Is this code for magento v1.7 only? what about v1.9? – user13274 Aug 18 '14 at 8:45
  • I have not idea, I still haven't got it working. – philtak Aug 19 '14 at 1:15
2

There is a way of doing that, but it's a bit ugly.
The url must look like this:

{ROOT}/directory/currency/switch/currency/{CURRENCY_CODE}/uenc/{ENCODED REDIRECT URL}/

So if your url is http://www.exmaple.com/sport-equipment/soccerball/, the url you send in the e-mail for EUR must look like this:

http://www.exmaple.com/currency/switch/currency/EUR/uenc/aHR0cDovL3d3dy5leG1hcGxlLmNvbS9zcG9ydC1lcXVpcG1lbnQvc29jY2VyYmFsbC8,

You can build this url starting from your url like this.

$currency = 'EUR';
$redirect = 'http://www.exmaple.com/sport-equipment/soccerball/';
$mageBaseUrl = `http://www.exmaple.com/`
$emailUrl = $mageBaseUrl.'directory/currency/switch/currency/'.$currency.'/uenc/'.strtr(base64_encode($redirect), '+/=', '-_,');

It's easier if you build the url in a magento environment:

$currency = 'EUR';
$redirect = 'http://www.exmaple.com/sport-equipment/soccerball/';
$emailUrl = Mage::getUrl('directory/currency/switch', array(
    'currency' => $currency,
    Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => Mage::helper('core')->urlEncode($redirect)
));
|improve this answer|||||
  • Thanks for the help. I need an extension that I can attach to ALL links and not just one link exmaple.com/sport-equipment/soccerball. I wonder why magento didint think about this, as really its an essential function, and I see many stores have some sort of link code in the url when you manually switch currency. – philtak Jul 17 '14 at 15:43
  • Marius, one questions, how will google crawlers reach to seeing two links exmaple.com/sport-equipment/soccerball and exmaple.com/sport-equipment/soccerball/…. Will they ban both of them from search engines ? or there something could be done in ROBOTS.TXT file so google picks up files with BASE currency only ? – philtak Jul 18 '14 at 22:06
  • I don't know how google crawlers work. – Marius Jul 19 '14 at 10:45

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