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

How to Get All Stores’ List by Website ID in Magento 2

By Sanjay JethvaUpdated on May 22, 2025 1 min read

Are you a Magento 2 store admin handling a website with multiple stores in it?

If so, this solution to get all stores’ list by website ID in Magento 2 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 get stock id of particular website in Magento 2.

For example, you would want to show different currencies for each store based on the target audience.

Or, you might want to implement a different design.

Method to Get All Stores’ List by Website ID in Magento 2:

Create app/code/Vendore/Extension/Helper/Data.php

<?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;
        parent::__construct($context);
    }
 
    public function getStoresList($websiteID)
    {
        $stores = $this->storemanager->getWebsite($websiteID)->getStores();;
        return $stores;
    }
}

That’s it.

Also, please share the solution with the Magento Community via social media.

Thank you.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.