Magento get Root Category Id

In Magento for getting root category id for current store view you should just run a code

<?php 
    $rootCategoryId = Mage::app()->getStore()->getRootCategoryId(); 
?>

For getting root category id of specific store view, you have to just pass store Id to getStore function

<?php 
    $storeId = 22;
    $rootCategoryId = Mage::app()->getStore($storeId)->getRootCategoryId(); 
?>

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.