Why are you trying to do this? Magento reads the current currency from a cookie which is set when you use the currency switcher input at the top of the page. Look at the option value for each currency:
http://example.com/directory/currency/switch/currency/CAD/uenc/some_form_key/
See: https://github.com/OpenMage/magento-mirror/blob/5345da52778cc6f5f31938ffd21fccfdd353435c/app/code/core/Mage/Core/Model/Store.php#L851
Seeing your comment, I think there could be a number of approaches here. Ultimately, you will need to call:
Mage::app()->getStore()->setCurrentCurrencyCode($code)
How you go about doing this is up to you. The problem I'm sure you're running into is that changing the visitor's currency requires a page reload to alter the cookie and those feed service crawlers I'm guessing just ignore the redirect.
You may need to create your own controller that will listen for a currency
parameter, set the store's currency, and then load/render the layout making it effectively look like your normal product page. You should also be able to refine the request flow based on the feed service crawler's user agent (which I'm guessing would be unique to that service). That way when someone visits your custom controller, you can just redirect them to the default product page.
Alternatively, you could rewrite the product controller to handle this as well, which might be a little cleaner in this case but you may wish to keep this stuff separate from your normal product controller.
I have found the solution.... which default magento currency change url
Copy app>code>Core>Mage>Directory>Helper>Url.php
to app>local>Core>Mage>Directory>Helper>Url.php
and change the code of function
public function getSwitchCurrencyUrl($params = array())
{
$params = is_array($params) ? $params : array();
if ($this->_getRequest()->getAlias('rewrite_request_path')) {
$url = Mage::app()->getStore()->getBaseUrl() . $this->_getRequest()->getAlias('rewrite_request_path');
}
else {
$url = $this->getCurrentUrl();
}
$params[Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED] = Mage::helper('core')->urlEncode($url);
if(strpos($_SERVER["REQUEST_URI"],'?')){
$CurrentUrl=$_SERVER["REQUEST_URI"].'&_currency=' .$params['currency'];
}else{
$CurrentUrl=$_SERVER["REQUEST_URI"].'?_currency=' .$params['currency'];
}
return $CurrentUrl;
//return $this->_getUrl('directory/currency/switch', $params);
}
Then goto
copy app/code/core/Mage/Core/Model/Url.php
to app/code/local/Mage/Core/Model/Url.php
function setRouteParams
add below code
if(!is_null($this->getRequest()->getParam('_currency'))):
if($this->getRequest()->getParam('_currency')==Mage::app()->getStore()->getCurrentCurrencyCode()){
}else{
Mage::app()->getStore()->setCurrentCurrencyCode($this->getRequest()->getParam('_currency'));
}
endif;
before code unset($data['_store_to_url']);
Modify function setRouteParams
public function setRouteParams(array $data, $unsetOldParams = true)
{
if (isset($data['_type'])) {
$this->setType($data['_type']);
unset($data['_type']);
}
if (isset($data['_store'])) {
$this->setStore($data['_store']);
unset($data['_store']);
}
if (isset($data['_forced_secure'])) {
$this->setSecure((bool)$data['_forced_secure']);
$this->setSecureIsForced(true);
unset($data['_forced_secure']);
} elseif (isset($data['_secure'])) {
$this->setSecure((bool)$data['_secure']);
unset($data['_secure']);
}
if (isset($data['_absolute'])) {
unset($data['_absolute']);
}
if ($unsetOldParams) {
$this->unsetData('route_params');
}
$this->setUseUrlCache(true);
if (isset($data['_current'])) {
if (is_array($data['_current'])) {
foreach ($data['_current'] as $key) {
if (array_key_exists($key, $data) || !$this->getRequest()->getUserParam($key)) {
continue;
}
$data[$key] = $this->getRequest()->getUserParam($key);
}
} elseif ($data['_current']) {
foreach ($this->getRequest()->getUserParams() as $key => $value) {
if (array_key_exists($key, $data) || $this->getRouteParam($key)) {
continue;
}
$data[$key] = $value;
}
foreach ($this->getRequest()->getQuery() as $key => $value) {
$this->setQueryParam($key, $value);
}
$this->setUseUrlCache(false);
}
unset($data['_current']);
}
if (isset($data['_use_rewrite'])) {
unset($data['_use_rewrite']);
}
if (isset($data['_store_to_url']) && (bool)$data['_store_to_url'] === true) {
if (!Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL, $this->getStore())
&& !Mage::app()->isSingleStoreMode()
) {
$this->setQueryParam('___store', $this->getStore()->getCode());
}
}
/* add by amit bera */
if(!is_null($this->getRequest()->getParam('_currency'))):
if($this->getRequest()->getParam('_currency')==Mage::app()->getStore()->getCurrentCurrencyCode()){
}else{
Mage::app()->getStore()->setCurrentCurrencyCode($this->getRequest()->getParam('_currency'));
}
endif;
/* end by amit bera */
unset($data['_store_to_url']);
foreach ($data as $k => $v) {
$this->setRouteParam($k, $v);
}
return $this;
}
Let me know ,if you have any issue.
Best Answer
There is a way of doing that, but it's a bit ugly.
The url must look like this:
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.
It's easier if you build the url in a magento environment: