I have two websites and am looking to create a dynamic Nav Bar that works across both store fronts.

Because I'm trying to make it dynamic I'll most likely load the current store_id then find the collection related to that.

Is there a way I can list the names of all the Product root categories for a given website?

and is there a way to get all the sub categories of the website?

Here is a picture of the categories I'm talking about as an example: enter image description here

Let me know if you have any questions or need clarification!

1 Answer 1


I solved it! For those curious,

First I grabbed the current store I'm in and the root category Ids

$store = Mage::app()->getStore();
$categoryId = $store->getRootCategoryId();

Then I loaded the Ids for root categories for the store and separated them into an array to sort through

$categories = Mage::getModel('catalog/category')->load($categoryId);
$categoryChildren = $categories->getChildren();
$categoryArray = explode(',', $categoryChildren);

Then I looped through them and grabbed their info

foreach($categoryArray as $category){
            $Category = Mage::getModel('catalog/category')->load($category);
            echo $Category->getName();
            echo "\r\n";
            echo $Category->getUrl();
            echo "\r\n";
  • are u getting sub categories of sub categories also ??
    – BornCoder
    Jan 18, 2017 at 5:23
  • yep, do you need any help? Jan 18, 2017 at 6:30

Your Answer

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

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