I'm building a tree view for my magento site. Its all working fine. But the only problem is that When I go into 4th level categories the URL path of the category is not coming properly.

for example.

Lets say I have the following url path


this is my 3rd level category url. The problem is that I would have another sub category under electronic like,


, but magento does not give me this path. it will only give upto the 3rd level category.

This is the code that I am using.

$cat = Mage::getModel('catalog/category')->load($category->getId());
echo Mage::getUrl($cat->getUrlPath());

any ideas?

  • Try with echo $cat->getUrl();
    – Marius
    Jul 28, 2014 at 5:55

1 Answer 1


Based on the comments...
You can get the url of a category like this:

$cat = Mage::getModel('catalog/category')->load($category->getId());
$url = $cat->getUrl();

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.