Using the StoreManagerInterface
I am getting the current store via $store = $this->storeManager->getStore()
.
I then want to get the code of the store. However, when using $store->getCode()
I get the code of the store view, not the store.
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager
){
$this->storeManager = $storeManager;
}
public function foo()
{
echo $this->storeManager->getStore()->getCode(); // returns store view code
}
Is there any way to just get the code of the store, not the store view?
Best Answer
For store group you can use