I am trying to switch stores programatically. I used following code to achieve it :

* @var \Magento\Store\Model\StoreManagerInterface

protected $_storeManager;

public function __construct(
 \Magento\Store\Model\StoreManagerInterface $storeManager
) {
$this->_storeManager = $storeManager;

and then :


as given in https://magento.stackexchange.com/a/173763/59686

But no success. Only default store is displayed(selected) on storefront.

I have also tried this url scheme http://mystoreurl.com/?___store=storeId but it only display the store with given id instead of switching the store completely, Means when i visit the main url (http:mystoreurl.com), it is again displaying default store. Is there any way to switch the store programatically just like it is selected as default from admin.

Or is there any way to add some readymade widget to switch stores (Store Switcher). The theme i am using does not have this feature to auto populate store switcher as default Magento Luma theme provides.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.