'How to setup Magento 2 store Switcher?

I want to setup website features for multiple store Magento 2 with store URL or store switcher Drop down.

Store Switcher comes by default in some themes but is not visible in my theme, so can somebody please help me out with creating a store switcher.



Solution 1:[1]

For some reasons your theme either hides the switcher, removes it or provide you with some configuration options to display it. I assume that you are familiar with theme's docs and there is nothing like an additional config. Therefore verify if switcher is not hidden (this is really poor solution but Magento's custom themes are overall poorly designed. If so then override styles or modify it directly.

If case is that it is removed from layout you can try to find store_switcher in *.xml of your custom theme to verify if it is really removed.

Nevertheless, to add it in any place of your layout simply edit appropriate xml file and add inside:

<referenceContainer name="name_of_your_container">
    <block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" template="Magento_Store::switch/stores.phtml" />
</referenceContainer>

Details like in which file add the customization depends on many factors and I can't be more helpful with provided data.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community