Get all Root-Category-IDs of all stores

This snippet gives you all entity_id’s of all Root-IDs of the Magento instance:

 * @return array Root-IDs of all stores
public function getAllRootIds(){#
    $aRootIds = array();
    $aRootIds[Mage_Catalog_Model_Category::TREE_ROOT_ID] = Mage_Catalog_Model_Category::TREE_ROOT_ID;
    $aAllStores = Mage::app()->getStores();
    foreach ($aAllStores as $iID => $store){
        $rootID = $store->getRootCategoryId();
    return array_keys($aRootIds);


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.