Hello Magento Friends,

Today we will learn to retrieve all stores of all websites in Magento 2.

Magento 2 provides the option to set up multiple websites and stores. When you need to retrieve the list of all stores, with default Magento you can get the stores for that particular website only. But if you have the requirement to get all the stores regardless of the website, this guide is for you.

Let me explain practically,

multiple stores

As per the above image, Indian-INR and Global-USD stores are available on different websites. So if you want to retrieve a list of all stores no matter what website they are in, you can use the below steps.

Steps to Get All Stores of All Websites in Magento 2:

Step 1: Go to the below file path


Then add the code as follows

Step 2: Now move to the following file path


After that add the following code snippet

Step 3: Finally, run the below commands


Hence, with the help of this method, you can get all stores lists of all the websites of your Magento 2 store. If you face any difficulty, share with me through the comment and stay tuned with us for more Magento solutions.

Happy Coding!

Click to rate this post!
[Total: 2 Average: 5]