User Tools

Site Tools



For more details see the Store Switcher extension page.

Guide for Store Switcher for Magento 2

Ease the shopping process for your international customers. Provide them with local store version including familiar language and currency. Store Switcher extension utilizes IP-addresses to detect location of your customers and switch them between store versions automatically.

  • Switch customers between different store versions automatically
  • Provide shoppers with familiar language and currency
  • Detect visitors' location
  • Exclude particular IP addresses and User Agents from redirection
  • Let customers choose store version manually

Database Installation

This product includes GeoLite2 Data created by MaxMind, available from 24.10.2023 (last update date).
You will need to install GeoIP database to make sure that the module works correctly and detects visitor's location.

To install the GeoIP database, go to Stores → Configuration → Amasty Extensions → GeoIP Data.

You can download and install the databases automatically or import your own data.

Hit the Download and Import button to make the extension download or update SQL dump file and import it into your database automatically.

In the Download and Import mode, don't be mislead by the error notification in the Import section, on the absence of CSV files: the CSV files are not needed, and the import will proceed.

To import files from your own source, use the Import option. Path to the files should look like this (the part 'var/amasty' should be replaced with your folders’ names):

In the Import section, the Import button is grayed out by default. It will be available right after you upload the CSV files. The red error notification will switch to green success notification when the import is completed.

If you face any difficulties when importing the location database, please see the following solution.

Extension Configuration

To configure the Store Switcher extension, go to Stores → Configuration → Amasty Extensions → GeoIP Redirect.

First, expand the General section.

Enable GeoIP Redirect — enable or disable the Store Switcher module.

Then, proceed to the Restriction section.

Apply Logic To — select the general logic of redirecting rules:

  • All URLs
  • Specified URLs
  • All Except Specified URLs
  • Redirect From Home Page Only

Excepted URLs — choose the Specified URLs or All Except Specified URLs options above to define the excepted URLs here.

User Agents to Ignore — ignore redirection rules for specified search engines.

Restriction by IP — restrict redirection for certain IP addresses.

First Visit Redirect Only — activate to enable redirection only for the first visit.

Beware that if you set this option to No, customer wouldn’t be able to switch store view and currency at their desire.

Redirect Between Websites — enable to redirect visitors between several websites.

Country to Store Redirect Configuration

Expand the Country to Store View Redirect section.

Enable Country –> Store View — enable to redirect visitors from certain countries to particular store views.

Switch the Store View dropdown menu to the required store version and define the list of countries that will be affected.

Now, visitors from the selected countries will see the defined store view version.

Countries and Currencies Mapping

Open the Country to Currency Switch section.

Enable Country –> Currency — set this option to Yes to automatically switch currency according to user’s location.

Country to Currency Mapping — define country — currency relation by selecting countries and the appropriate currencies. Hit the Add button to create a new relation.

Country to URL Redirect

Then, proceed to the Country to URL Redirect section.

Enable Country –> URL — enable to redirect visitors from certain locations to any other URL.

Country to URL Mapping — select locations and specify the URL that would be used to redirect visitors to. Use the Add button to create a new country — URL relation.

If you enable the Use Website checkboxes for the mapping options, the same set of rules would be applied to the Main Website and the selected Store View.


GeoIP Data Import Failure

Sometimes, it is unable to complete the database import due to execution time limit of PHP scripts. You can avoid this error by increasing the maximum execution time for your PHP scripts.

You need to set the max_execution_time to the number of seconds that all your scripts are allowed to run in your PHP's configuration file. The file location may differ from system to system but in general you need to find the PHP.INI file and modify it.

We need to set the value to 18000.

For example:

; Maximum execution time of each script, in seconds
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 18000

Setting the value to 0 means there's no time limit.

You'll have to restart your web server for this solution to work.

Varnish Cache Compatibility

To make the switcher functionality work with Varnish Cache enabled, it is necessary to change just a few things in the web server configuration:

1. For nginx - add the following code in any place of the nginx.conf file:

set_real_ip_from <varnish-ip>;

2. For apache - add the following code in any place of the .htaccess file:

RemoteIPTrustedProxy <varnish-ip>;

Where <varnish-ip> is an IP address of the Varnish server.

You can contact a hosting provider to change the web server configuration or do it on your own. With an independent change, you need to have root access and restart the server after the changes are implemented.


Find out how to install the Store Switcher extension via Composer.

Rate the user guide
 stars  from 3 votes (Details)
magento_2/store_switcher.txt · Last modified: 2024/04/09 06:43 by kkondrateva