In Magento 2 admin side, I added store switcher in phtml file using this code.

protected function _prepareLayout()
        return parent::_prepareLayout();

So above code show store selection in phtml file as below,

enter image description here

When I select diffrent store from the list, then admin URL is change, but when I access store information in phtml like this $this->_storeManager->getStore()->getCode()

but it always return "default" not selected store code. Can Any one have idea.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" layout="admin-2columns-left">
        <referenceContainer name="page.main.actions">
            <block class="Magento\Backend\Block\Store\Switcher" name="store_switcher">
                <action method="setUseConfirm">
                    <argument name="params" xsi:type="string">1</argument>
  • Thanks for the answer. But I already solve the problem. – Dhiren Vasoya May 2 '18 at 13:22
  • but you can accept answer) or publish yours ;) – Slava Yurthev May 6 '18 at 12:14

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.