Magento 2 – Get Store ID by Store Code magento2store-codestore-id How to get Store ID by store code in Magento 2 Thanks Best Answer Please use below code : $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $storeManager = $objectManager->create("\Magento\Store\Model\StoreManagerInterface"); $storecode = 'de'; //storecode here // get array of stores with storecode as key $stores = $storeManager->getStores(true, true); // check stores array for this storecode if(isset($stores[$storecode]){ $store_id = $stores[$storecode]->getId(); } echo $store_id; Related SolutionsHow to Check if ‘Add Store Code to URLs’ is Enabled by Admin in Magento 1.9 You can check if the store codes are included in the URL like this: $flag = Mage::getStoreConfigFlag('web/url/use_store'); $flag will be true or false depending on the store codes in URL are enabled or not. Magento2 – Get Store URL Without Store Code [SOLVED] I have found solution. Bellow is my code. <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $conf = $objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface')->getValue("web/unsecure/base_url");?> Thanks. Related TopicMagento 2 – How to Get Store Code Instead of Store View CodeMagento – How to get root category using store id in magento 2 block file
Best Answer
Please use below code :