How to get all store ids assigned to specific website Magento 2?

You can get all the stores id assigned to Specific website Using Magento 2.

Retrieve the Store website relation by the website id to fetch the number of store a specific website has available.

Useful Interface class:
Magento\Store\Api\StoreWebsiteRelationInterface

Let’s Consider Base(id 1) website with two stores available,
1. English Store. (id 3)
2. French store. (id 4)

Call from the class,
echo $getStoreIds = $this->getStoreIds();

Output: Array of store ids.

Result will be all the store id to the website in system.

Leave a Reply