Magento – Get storeviews by group ID in magento

magento-1.7multistorestore-view

How to get storeview ID (view) by group_id (store) in Magento? Basically I want to list storeviews by their store_id.

Mage::app()->getStores() will get all storeviews, but I want to filter it by specific store group like

Mage::app()->getStores()->byGroupId($store_group_id);

so i can list all storeviews under a specific store.

Best Answer

$groupId = 1;
$collection = Mage::getModel('core/store')->getCollection()->addFieldToFilter('group_id', $groupId);
foreach ($collection as $store) {
    //do something with $store
}
Related Topic