Magento – Get all stores

Here is how to get all stores of your Magento instance a an Array:

$aAllStores = Mage::app()->getStores();
foreach ($aAllStores as $iStoreId => $oVal){
    $sStoreCode = Mage::app()->getStore($iStoreId)->getCode();
    $sStoreName = Mage::app()->getStore($iStoreId)->getName();
    $iStoreId = Mage::app()->getStore($iStoreId)->getId();

    echo $sStoreCode;
    echo $sStoreName;
    echo $iStoreId;

To include the admin store you can call getStores like that:

$aAllStores = Mage::app()->getStores(true)

A much simpler way to get all stores is:

$aAllStores = Mage::getModel('core/store')->getResourceCollection()->toOptionArray();



Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.