🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How To Get Default Store ID in Magento 2

By Jignesh ParmarUpdated on May 22, 2025 1 min read

In Magento 2, it is possible creating a website with multiple stores having different designs, products, purposes, etc. Store view is nothing but, a variation of the same store with different attributes.

For example, in the case of different geographical regions, the attributes such as product title and description have to be translated into different languages. Thus, the store owner needs to create multiple store views with multiple languages.

However, every Magento 2 store has a default store view. The store owner may require to get the default store ID in Magento 2 programmatically for various purposes. For example, if you want to show the default Magento store view in a drop-down menu to the customers, you may require to retrieve the default store view of that particular Magento website.

You can refer to the solution provided here to get the default store ID in Magento 2.

Method to Get the Default Store ID in Magento 2

use Magento\Store\Model\StoreManagerInterface;
protected $storeManager;
public function __construct(StoreManagerInterface $storeManager)
{
$this->storeManager = $storeManager;
}
$websiteId =1;
// get default store id of website 1
$storeId = $this->storeManager->getWebsite($websiteId)->getDefaultStore()->getId();

That’s it.

Do consider sharing this post with the Magento community via social media.

Thank You.

Jignesh Parmar Full Image
Article byJignesh Parmar

An expert in his field, Jignesh is the team leader at Meetanshi and a certified Magento developer. His passion for Magento has inspired others in the team too. Apart from work, he is a cricket lover.