8/30/2010

How to get all Store Ids in Magento

<?php
$allStores = Mage::app()->getStores();
foreach ($allStores as $_eachStoreId => $val)
{
$_storeCode = Mage::app()->getStore($_eachStoreId)->getCode();
$_storeName = Mage::app()->getStore($_eachStoreId)->getName();
$_storeId = Mage::app()->getStore($_eachStoreId)->getId();
echo $_storeId;
echo $_storeCode;
echo $_storeName;
}
?>

5 comments:

  1. very useful, thanks

    ReplyDelete
  2. Why not use simply $val->getCode() etc. instead of Mage::app()->getStore($_eachStoreId)->getCode() ?

    ReplyDelete
  3. Thanks, quick and dirty but exactly what I needed!

    ReplyDelete
  4. hi,
    any help for doing the same in java

    ReplyDelete