{"id":1922,"date":"2021-10-11T12:45:36","date_gmt":"2021-10-11T12:45:36","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/get-all-stores-list-by-website-id-in-magento-2\/"},"modified":"2025-05-22T09:55:20","modified_gmt":"2025-05-22T04:25:20","slug":"get-all-stores-list-by-website-id-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/get-all-stores-list-by-website-id-in-magento-2\/","title":{"rendered":"How to Get All Stores&#8217; List by Website ID in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Are you a Magento 2 store admin handling a website with multiple stores in it?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If so, this solution to&nbsp;<em><strong>get all stores\u2019 list by website ID in Magento 2<\/strong><\/em>&nbsp;might be useful to you when you would want to implement different store-wise functionalities in your website. Likewise, in order to work with inventory among multiple warehouses easily, generate inventory-related reports, and manage stock effectively, one often needs to&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/get-stock-id-of-particular-website-in-magento-2\/\">get stock id of particular website in Magento 2<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, you would want to show different currencies for each store based on the target audience.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Or, you might want to implement a different design.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Get All Stores\u2019 List by Website ID in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create&nbsp;<strong>app\/code\/Vendore\/Extension\/Helper\/Data.php<\/strong><\/p>\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=\"\">&lt;?php namespace Vendore\\Extension\\Helper; use Magento\\Framework\\App\\Helper\\AbstractHelper; use Magento\\Framework\\App\\Helper\\Context; use Magento\\Store\\Model\\StoreManagerInterface; class Data extends AbstractHelper { protected $storemanager; public function __construct( Context $context, StoreManagerInterface $storemanager ) { $this->storemanager = $storemanager;\n        parent::__construct($context);\n    }\n \n    public function getStoresList($websiteID)\n    {\n        $stores = $this->storemanager->getWebsite($websiteID)->getStores();;\n        return $stores;\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, please share the solution 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>Are you a Magento 2 store admin handling a website with multiple stores in it? If so, this solution to&nbsp;get all stores\u2019 list by website&#8230;<\/p>\n","protected":false},"author":5,"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-1922","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1922","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\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1922"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1922\/revisions"}],"predecessor-version":[{"id":14209,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1922\/revisions\/14209"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1922"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}