简体   繁体   English

Magento设置基础货币-Geoip查找

[英]Magento set base currency - geoip lookup

I'm trying to set the currency based on IP lookup. 我正在尝试根据IP查找设置货币。

So far I've found only this php snippet for setting the currency http://ravikumar85.blogspot.ie/2010/02/magento-set-base-currency-through-code.html 到目前为止,我仅找到了用于设置货币的该PHP代码段http://ravikumar85.blogspot.ie/2010/02/magento-set-base-currency-through-code.html

but if I put this code in index.php just before Mage::run() 但是如果我将这段代码放在Mage :: run()之前的index.php中

if($geolookup == 'UK') {
    Mage::app()->getStore()->setCurrentCurrencyCode('GBP');
}

I get this error 我得到这个错误

There has been an error processing your request
Mage registry key "controller" already exists

Any idea? 任何想法?
Thanks 谢谢

I'm not sure the reason you wish to have the custom modification. 我不确定您希望进行自定义修改的原因。 Anyway, modify the app/code/core/Mage/Core/Model/Store.php by adding the below code will work you the solution. 无论如何,通过添加以下代码来修改app / code / core / Mage / Core / Model / Store.php将为您提供解决方案。

public function getCurrentCurrencyCode()
{
  if($geolookup == 'UK') {
      $this->_getSession()->setCurrencyCode('GBP');
  }

  ......
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM