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?

  • @SureshChikani It was already in the original post. Nevertheless I have added a more precise example.
    – fritzmg
    May 11, 2018 at 13:15

1 Answer 1


For store group you can use

  • Thx :). Didn't know that this was called a "group".
    – fritzmg
    May 11, 2018 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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