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


so i can list all storeviews under a specific store.

3 Answers 3

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

You can use something like this

$stores = Mage::getModel('core/store')->getCollection()->addFieldToFilter('group_id',$store_group_id);
foreach($stores as $store)
$stores = Mage::getResourceModel('core/store_collection')
    # $yourStoreGroupIds can be string or array of group ids

foreach ($stores as $store) {

Technically the same as Marius answer because addGroupFilter uses

public function addGroupFilter($groupId)
    return $this->addFieldToFilter('main_table.group_id', array('in' => $groupId));

To just get the storeview IDs

$storeIds = $stores->getColumnValues('store_id');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.