Get Category Url from ID in Magento

Use the below code to get the category url from the category ID in magento

$category_id = 14;


5 comments on “Get Category Url from ID in Magento

  1. Using Magento (Category-) models might become very heavy to load just for loading the URL of category. When you’re in a loop where you need to load the URL’s of 9000+ category URL’s you might consider using the url rewrite functionality to fetch the URL’s since it doesn’t involve loading numerous Magento models:

    $requestPath = Mage::getSingleton('core/url_rewrite')
    'category/' . $categoryId, Mage::app()->getStore()->getId());
    return Mage::getBaseUrl() . $requestPath;

    Read this article for more information on this one:

Leave a Reply

Your email address will not be published. Required fields are marked *