Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Switching language and currency when having multiple websitecodes in Magento’s index.php
 
sonician
Member
 
Total Posts:  49
Joined:  2008-11-29
 

I’m looking to switch language and currency when I have multiple websitecodes in Magento.

I wonder if there’s a way to include the store-view-name, and preferrably set the currency, when doing a website-code switch between multiple URLs in index.php like:

switch($_SERVER['HTTP_HOST']{
case 'website1.com':
Mage::run('website1''website');
break;
case 
'website2.com':
Mage::run('website2''website');
break;

The wiki on http://www.magentocommerce.com/wiki/how-to/how_to_automatically_redirect_to_a_store_view_based_on_the_browser_language uses the web-browser settings rather than the IP-address lookup, but the main problem is that it’s for a one-website shop only, and not for when you have multiple URLs, too. (Unless I’ve missed something).

Unfortunately, the server doesn’t allow doing a htaccess redirect based on http://www.maxmind.com/app/mod_geoip which I think would have solved the issue there, so I would need to, like the wiki-post, do something with index.php (either by using the wiki-post or http://www.maxmind.com/app/php) preferrably, just getting the language and currency with the multiple websitecodes to go along with it…

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

Hi again
There is a way of running a store view directly.
When you call something like this:

Mage::run('website1''website');
the default store view from website1 will run.
Let’s say in website1 you have a store view called store_view_1. You can run it like this.
Mage::run('store_view_1');
As for the currency, you can set a default currency for each store view.
For example you can have to identical store views (in English), one with default currency ‘EUR’ and one ‘GBP’.
Let’s say the first one is called store_view_eur, and the second one store_view_gbp.
You can run them like this.
if (some condition){
Mage
::run('store_view_eur');
}
else{
Mage
::run('store_view_gbp');
}
As for the IP location, sorry but I don’t think I can help you much there.

for security reasons you can find a copy of this post here:
http://marius-strajeru.blogspot.com/2009/12/switching-language-and-currency-when.html

 
Magento Community Magento Community
Magento Community
Magento Community
 
FMEExtensions
Mentor
 
Avatar
Total Posts:  1298
Joined:  2009-08-07
 

Not sure if this is what you are looking for but with the following module you can set the Currency and language for every country with the following module.

http://www.fmeextensions.com/magento-geo-ip-default-language-currency.html

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top