I have created multiple stores in one. Now when I change the store view it definitely changes and I have set the Base URLs for this store view accurately.
But when I try to get the current store view URL or Name I got the default store view name and URL.
I am trying to get using $storeManager->getStore()->getBaseUrl()
Any idea how I can get this ?
Magento – Get URL of Current Store View Store Magento 2
base-urlmagento2multistorestore-view
Best Answer
What you have to understand is the baseUrl is the same even you have multiple store views. the value that changes is for example : StoreId, StoreCode, storeName etc...
If you want to get the baseUrl, it will be the same in all stores :
if you want to get the currentUrl, it will be different in each store :
If you want to set à specific store view, you append at the url
?___store=storeviewcode
: