In the home page of my Magento store I have created a featured category section where I have placed a button with drop down where I would like to list any specific categories name and link as a drop down list with the help of category id (Get only the category name and link to it those IDs are specified, not the sub-categories of it). How do I accomplish it in a .phtml file? Very new to magento so every help will be a lot for me.

1 Answer 1


To Display Top Level Category only Try the Below code...

<?php $_helper = Mage::helper('catalog/category') ?> // create a object of helper class.
<?php $_categories = $_helper->getStoreCategories() ?> // fetch you store category
<?php if (count($_categories) > 0): ?>
    <?php foreach($_categories as $_category): ?>
            <a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
                <?php echo $_category->getName() ?>
    <?php endforeach; ?>
<?php endif; ?>

You have

  <?php $_helper = Mage::helper('catalog/category') ?> // create a object of helper class.

Just put the code in your .phtml file and make CSS as per you need.

  • Thanks, I don't want to get all the store categories but specific categories that are under Default Category >> Inventory. I think I have to use something like Mage::getModel('catalog/category')->getCategories(4);
    – Kevin S
    Commented Sep 26, 2014 at 13:46
  • 1
    no if you have category Id then $data=Mage::getModel('catalog/category')->load(4) Simple and print print_r($data->getData())
    – Keyul Shah
    Commented Sep 26, 2014 at 14:46

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.