{"id":1996,"date":"2022-01-05T07:51:26","date_gmt":"2022-01-05T07:51:26","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/get-default-store-id-in-magento-2\/"},"modified":"2025-05-22T09:19:47","modified_gmt":"2025-05-22T03:49:47","slug":"get-default-store-id-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/get-default-store-id-in-magento-2\/","title":{"rendered":"How To Get Default Store ID in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, every Magento 2 store has a default store view. The store owner may require&nbsp;<em><strong>to get the default store ID in Magento 2&nbsp;<\/strong><\/em>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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can refer to the solution provided here to get the default store ID in Magento 2.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Get the Default Store ID in Magento 2<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">use Magento\\Store\\Model\\StoreManagerInterface;\nprotected $storeManager;\npublic function __construct(StoreManagerInterface $storeManager)\n{\n$this->storeManager = $storeManager;\n}\n$websiteId =1;\n\/\/ get default store id of website 1\n$storeId = $this->storeManager->getWebsite($websiteId)->getDefaultStore()->getId();<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do consider sharing this post with the Magento community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank You.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1996","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1996","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1996"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1996\/revisions"}],"predecessor-version":[{"id":14167,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1996\/revisions\/14167"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1996"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1996"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}