How to get category name by category id in Magento

There are scenarios when you look for information using category id in Magento and there are Name, description, url, thumbnail, level and parent category that can be fetched from this code respectively. These are the following ways by which we can fetch Display category name by category id in Magento.


Magento Get all Categories name and description

<?php

$categoryId = 10; // Change category id according to your requirements

// display name and other detail of all category 
$_category = Mage::getModel('catalog/category')->load($categoryId);

?>

Magento get category name

<?php

// category name with this code
echo $categoryName = $_category->getName();

?>

Magento get category description

<?php

// For category description 
echo $categoryDescription = $_category->getDescription();

?>

Magento get category URL

<?php

// For category url 
echo $categoryUrl = $_category->getUrl();

?>

Magento get category Image URL

<?php

//For Category Image
echo $image=$Category->getImageUrl()

?>

Magento get category Thumbnail

<?php

// For category thumbnail 
echo $categoryThumbnail = $_category->getThumbnail();

?>

Magento get category Level

<?php

// For category level 
echo $categoryLevel = $_category->getLevel();

?>

Magento get parent category id

<?php

// For parent category
echo $parentCategoryId = $_category->getParentId();

?>

You can get all the specific information using these codes only!


You may also like...

Leave a Reply

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