How to Get All Stores’ List by Website ID in Magento 2
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.
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:
class Data extends AbstractHelper
public function __construct(
$this->storemanager = $storemanager;
public function getStoresList($websiteID)
$stores = $this->storemanager->getWebsite($websiteID)->getStores();;
Any doubts? If so, do mention them in the Comments section below. I’d be happy to help.
Also, please share the solution with the Magento Community via social media.