How to get all Store Ids in Magento

If you want to get all IDs of available store views in your Magento store you can just use this code

<?php
    $allStores = Mage::app()->getStores();
    $allStoreIds = array_keys($allStores);
?>

but if you want to get more information about each store, you can use this code:

<?php
$allStores = Mage::app()->getStores();

foreach ($allStores as $storeId => $storeObject) {
    
    $storeCode = $storeObject->getCode();
    $storeName = $storeObject->getName();
    
}
?>

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.