如何根据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();
答
在分类页面,你可以像这样得到的信息:
$category = Mage::registry('current_category');
echo $category->getName();
答
它在分类模型中工作。
$Category=Mage::getModel('catalog/category')->load($cat);
$cat_name=$Category->getName();
谢谢@ pankaj先生。 –