Magento 2How To GuideMay 10, 2024Simon Walker

How to Setup Magento 2 Website Switcher?

How to Setup Magento 2 Website Switcher?

Competition in the world of eCommerce is heating up due to the ease with which you can set up an online store these days. To offset this competition, online businesses are always on the lookout for expanding their reach. Magento is perfectly set up for this purpose. It is one of the most preferred and liked platforms for eCommerce sites that empowers thousands of retailers & brands across the globe.

The platform offers greater scalability, security, and performance. How does it allow merchants to expand their reach? One of the most appealing features in Magento 2 is that you can create new websites, stores, store views and configure them for specific regions. In other words, you can create multiple websites and manage them all using a single Magento instance.

Of course, this is a relatively complex job, and beginners may find it difficult to configure multiple websites, stores, store views and setting up their URLs. So here we are to provide a step-by-step tutorial to help you do this. Before we delve into the steps, let’s talk about the various benefits of a store switcher. This will help you grasp a deeper understanding of this function.

Understanding the Benefits of a Store Switcher

If you search for ‘store switcher Magento 2’, you will come across various Magento 2 store switcher extensions. But there’s no point in checking them out until you understand the benefits. So, let’s touch upon them briefly:

Improved User Experience

Suppose your store serves different geographical locations. These locations represent different languages and cultures. For instance, the US and China. Both are poles apart in terms of culture and language. If a customer from China lands on the US website, they won’t understand a thing since English is not their primary language. What would truly enhance his experience? Naturally, if they are automatically redirected to the store’s Chinese version, they can start browsing products right away. This improves chances of conversion.

Expansion

Its impossible to serve geographically diverse markets using a single website. Apart from the language, product preferences would vary. From a marketing perspective, the keywords will be quite different. You cannot optimise a single store for different markets. Thus, you need multiple stores that are localised to each market. It means the language, currency, products, and everything is based on the local requirements. This allows merchants to expand overseas efficiently.

Adaptability

The conditions vary in each market. Multiple stores allow you to adapt to the conditions of each market. For example, in the EU, you must adapt to the General Data Protection Regulation (GDPR). In California, US, you must comply with the California Consumer Privacy Act. With a single store, it is impossible to adapt to various markets.

The Purpose of Creating Store Switcher & Website Switcher in Magento 2

Creating multiple websites, merchants can showcase products and services in various categories on the website with different checkout & shipping methods. Use the Store Switcher Extension by FME in order to add an auto store switcher functionality to your Magento 2 website.

magento-2-store-switcher

Store Switcher

Magento 2 Store Switcher extension directs users to region-specific storefronts.

Follow the steps below to setup multiple websites, stores & store views in Magento 2.

Create Websites

In order to add Magento 2 website switcher functionality, you need to create websites by following these steps:

  • Log in to the Magento Admin Panel with an account authorized to create websites, stores, and store views.
  • Click Stores > Settings > All Stores
  setup-new-website-switcher-in-magento-2
  • On the Stores page, click Create Website
  setup-website-switcher-in-magento-2   Once the page loads, fill in the following required fields.
  • Name - Enter website name
  • Code - Enter a unique code to identify the website, e.g. German website
  • Sort Order - Set website sort order.
  • Click Save Web Site
  configure-website-switcher-in-magento-2  

Create Stores

Each Website must have at-least one store. In order to create a store, follow these steps:
  • In the Magento Admin panel, click Stores > Settings > All Stores
  • On the Stores page, click Create Store.
  create-store-switcher-in-magento-2   Once the page loads, fill the required fields.
  • Website - If you have multiple websites, then choose the website with which you want to associate this store
  • Name - Enter Store name
  • Code - Enter a unique code for each store
  • Root Category - If you’re having multiple root categories, select a root category for this store.
  configure-store-switcher-in-magento-2 NOTE: Create a unique root category, if you want to have unique root category for each store/website.

Create Store View

Each store must have a store view. In order to create a store view, follow these steps:
  • In Magento Admin panel, click Stores > Settings > All Stores.
  • On the Stores page, click Create Store View.
  create-store-view-in-magento-2   Once the page loads, fill the required fields.
  • Store - If you have multiple stores, then choose the store with which you want to associate this store view.
  • Name - Enter store view name, e.g. german store view
  • Code - Enter a unique code for each store view, e.g. de for german store view
  • Sort Order - Set store view sort order.
  • Click Save Store View
  configure-store-view-in-magento-2  

Change the Website Base URL

To access a website using a unique URL like https://german.fmeplugins.net, you must change the Base URL for each website in the Magento Admin Panel.

To change the Website Base URL, follow these steps:

  • Open Magento Admin panel, click Stores > Settings > Configuration
  • Now Click General > Web
  • From the Store View list at the top of the page, click the name of one of your websites as shown below.
  setup-website-switcher-base-url-in-magento-2   Once the page loads, Click Base URLs section
  • In the Base URLs section, Uncheck the Use Default
  • Enter the URL in the Base URL and Base Link URL fields. E.g https://german.fmeplugins.net/ or https://example.com/magento/
  • Now Repeat the above steps for the Base URLs (Secure) section as well
  • Click Save Config
  setup-website-switcher-base-url-in-magento-2

Change the Default Store View Base URL

  • Open Magento Admin panel, click Stores > Settings > Configuration
  • Now Click General > Web
  • From the Store View list at the top of the page, click the Default Config
  setup-website-switcher-base-url-in-magento-2 Once the page loads, Click Base URLs section
  • In the Base URLs section, Uncheck the Use system value
  • Enter the Base URL in the Base URL and Base Link URL fields
  • Now Repeat the above steps for the Base URLs (Secure) section
  • Click Save Config
  setup-website-switcher-base-url-in-magento-2  

Add the Store Code to the Base URL

  • On the Admin sidebar, Click Stores. Then under Settings > choose Configuration
  • In the left panel, Click & Expand General > Click Web
  • From the Store View dropdown menu at the top of the page, Select Default Config
  • Expand the URL Options section
  • Uncheck the Use System Value against Add Store Code to Urls field
  • Set Add Store Code to YES and Click Save Config
  add-store-switcher-code-to-base-urls-in-magento2

Once configuration is saved, a prompt message will appear to flush cache

Flush Magento 2 Cache:

  • To Flush Magento cache, Click System > Cache Management on Admin sidebar.
  • Once Cache Management page loads, Click Flush Magento Cache button on right top bar.

URL with Store Code - http://www.yourdomain.com/magento/[store-code]/index.php/url-identifier

URL without Store Code - http://www.yourdomain.com/magento/index.php/url-identifier

For more information regarding Store Base URLs, see the Magento User Guide

How to Add Auto Store Switcher in Magento 2 Website?

In order to automate this process, I would recommend using Magento 2 GeoIP Default Store Switcher Extension, which enables you to create & configure multiple stores for different countries or regions. This extension automatically detects the visitor location from their IP address and redirect them to the region optimized store. Visitors can also manually switch to another store from the store switcher popup at the footer of the homepage.

Key Features:

  • Redirect Users to Relevant Store Based on Their Location
  • Create Rules, Select Countries & Assign Stores to Diff. Countries
  • Automatically Detects Visitors’ Locations by IP Address
  • Setup Manual or Automatic Redirection
  • Provide the IPs List to Exempt from Store Switching Rule

Configure Auto Store Switcher in Magento 2

You can now configure and personalize a store for a specific country or region once you have created stores, store views & installed GeoIP Store Switcher extension for Magneto 2. For this you need to create a store switching rule.

Creating a Store Switching Rule

From Admin Sidebar Tap FMEextensions > Click Manage GeoIP Default Store Once GeoIP Default Store Information page loads, enter the following information:

  • Title – Set title of the rule, e.g for redirecting European visitors to European store view, etc.
  • Priority – Set priority of the store switcher rule
  • Store Group – Select a store that you have created
  • Status – Enable/Disable the Store Switcher rule
  • IP Exceptions - Enter specific IP addresses to white-list/overrule the store switcher rule
  • Description – Enter description of the store switcher rule
  • Now on left side, click Countries tab, here you can select a country or countries that you want to redirect its visitors to the selected store
  • Click Save Rule
  magento-2-store-switcher

NOTE: You can update the country list by importing a latest Maxmind database.

Store Switcher Extension Configurations:

  • You can Enable/Disable the Store Switcher Extension
  • Auto Redirect - If Enabled, the visitor will be redirected to the assigned store automatically & if Disabled, a store switcher popup will be prompted. Visitors can manually select a store.
  • Popup Title - Enter Popup title
  • Popup Button Text - Enter Text for Popup button, e.g. continue, enter, etc.
  7-GEOIP-Default-Store-Switcher-Extension
  • Import Countries List - This extension uses Maxmind Country IP database for Geo Information. You can download the latest Maxmind database here and upload it at the Magento Admin panel.
  import-maxmind-database-magento-2

Final Thoughts on Magento 2 Store Switcher

This concludes our article on setting up a Magento 2 website switcher. The article also touched upon GeoIP Magento 2 extension. If you have any questions, don’t hesitate to contact us. Thank You.