Magento 目录产品子类别名称
Magento Catalog Product SubCategory Name
我正在实现 Magento 目录产品视图页面,我需要产品添加到的子类别的名称。
显示类别的代码如下:$_product->category->name
但是我无法获取子类别名称。
要获取类别的子类别,请使用以下代码
$your_category_id = '2334'; // category_id whose subcategory you want to fetch
$subcats = Mage::getModel('catalog/category')->getCategories($your_category_id);
foreach ($subcats as $sub) {
echo $sub->getName();
}
好吧,我通过以下方式获得了子类别:
<?php
if (Mage::registry('current_product')) {
if ($_product) {
$categoryIds = $_product->getCategoryIds();
$cat_id = $categoryIds[0]; ----> pass the level of sub catgeory to the array index
$category = Mage::getModel('catalog/category')->load($cat_id);
$cat_name = $category->getName();
}
}
?>
我正在实现 Magento 目录产品视图页面,我需要产品添加到的子类别的名称。
显示类别的代码如下:$_product->category->name
但是我无法获取子类别名称。
要获取类别的子类别,请使用以下代码
$your_category_id = '2334'; // category_id whose subcategory you want to fetch
$subcats = Mage::getModel('catalog/category')->getCategories($your_category_id);
foreach ($subcats as $sub) {
echo $sub->getName();
}
好吧,我通过以下方式获得了子类别:
<?php
if (Mage::registry('current_product')) {
if ($_product) {
$categoryIds = $_product->getCategoryIds();
$cat_id = $categoryIds[0]; ----> pass the level of sub catgeory to the array index
$category = Mage::getModel('catalog/category')->load($cat_id);
$cat_name = $category->getName();
}
}
?>