Search This Blog

Tuesday 4 September 2012

Get all websites and stores in Magento

foreach (Mage::app()->getWebsites() as $website) {
    foreach ($website->getGroups() as $group) {
        $stores = $group->getStores();
        foreach ($stores as $store) {
            //$store is a store object
        }
    }
}

4 comments:

  1. Thank you! Your example was very usefull for my custom magento api: https://github.com/JumpLink/magento-api/blob/master/src/app/code/local/JumpLink/API/Model/Store/Api.php

    ReplyDelete
  2. Will this code display or fetch all magento websites. If not is there a way to fetch all magento websites.

    ReplyDelete
  3. I do agree with all the ideas you have presented in your post. They’re really convincing and will certainly work. Still, the posts are very short for newbies. Could you please extend them a little from next time?..Keep this great work
    magento development company in bangalore 

    ReplyDelete