Use the below code to get the category url from the category ID in magento
$category_id = 14; Mage::getModel("catalog/category")->load($category_id)->getUrl();
Cheers!
Amjath
Use the below code to get the category url from the category ID in magento
$category_id = 14; Mage::getModel("catalog/category")->load($category_id)->getUrl();
Cheers!
Amjath
5 comments on “Get Category Url from ID in Magento”
Its works,,,,thanks
where i’ll write this code?
@karthick
You can use this even in the theme files(.phtmls)
Cheers!
Amjath
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')
->getResource()
->getRequestPathByIdPath(
'category/' . $categoryId, Mage::app()->getStore()->getId());
return Mage::getBaseUrl() . $requestPath;
Read this article for more information on this one: http://gielberkers.com/get-magento-category-url-without-loading-category/
It works thanks 🙂