Home » Magento, Magento 25 May 2016

Magento 2: Get Store Information (Store ID, Code, Name, URL, Website ID)

This article shows how we can get store information in Magento 2. We will be fetching store id, store code, store name, store url, and store’s website id. We also write a function which checks if the store is active or not.

Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of StoreManagerInterface in the constructor of my module’s block class.

app/code/Chapagain/HelloWorld/Block/HelloWorld.php

See more functions in vendor/magento/module-store/Model/Store.php.

Now, we print the store information in our template (.phtml) file.

Using Object Manager

Hope this helps. Thanks.

Magento 2

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • itsnotclear

    it’s not clear how to use this code.

  • riad lynx

    thank you very much