如何在Magento中按类别ID获取类别名称

时间:2017-04-20 12:31:38

标签: magento categories

如何在类别页面上的magento中按类别ID获取类别名称? 在此先感谢,请建议我。

3 个答案:

答案 0 :(得分:2)

请按类别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();

答案 1 :(得分:0)

在类别页面上,您可以获得以下信息:

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

答案 2 :(得分:0)

适用于分类模型。

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