【发布时间】:2017-04-20 12:31:38
【问题描述】:
如何在类别页面上的 magento 中通过类别 id 获取类别名称? 提前谢谢请给我建议。
【问题讨论】:
标签: magento categories
如何在类别页面上的 magento 中通过类别 id 获取类别名称? 提前谢谢请给我建议。
【问题讨论】:
标签: magento categories
请按类别 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();
【讨论】: