如何根据Magento中的类别id获取类别名称

如何根据Magento中的类别id获取类别名称

问题描述:

如何根据类别页面上的类别id获取类别名称? 在此先感谢请给我建议。如何根据Magento中的类别id获取类别名称

请按类别ID使用的类别名称下面的代码。也得到缩略图等。

$categoryId = 5; // Change category id according to you or use dynamic category variable 

// display name and other detail of all category         

$_category = Mage::getModel('catalog/category')->load($categoryId); 

echo $categoryName = $_category->getName(); 

echo $categoryDescription = $_category->getDescription(); 

echo $categoryUrl = $_category->getUrl(); 

echo $categoryThumbnail = $_category->getThumbnail(); 

echo $categoryLevel = $_category->getLevel(); 

echo $parentCategoryId = $_category->getParentId(); 
+0

谢谢@ pankaj先生。 –

在分类页面,你可以像这样得到的信息:

$category = Mage::registry('current_category'); 
echo $category->getName(); 

它在分类模型中工作。

$Category=Mage::getModel('catalog/category')->load($cat); 
    $cat_name=$Category->getName();