clo*_*eek 66
$children = Mage::getModel('catalog/category')->getCategories(10);
foreach ($children as $category) {
echo $category->getName();
}
Run Code Online (Sandbox Code Playgroud)
如果您想获得每个当前类别的子类别,此代码可能会有所帮助
<?php
$layer = Mage::getSingleton('catalog/layer');
$_category = $layer->getCurrentCategory();
$currentCategoryId= $_category->getId();
$children = Mage::getModel('catalog/category')->getCategories($currentCategoryId);
foreach ($children as $category)
{
echo $category->getName(); // will return category name
echo $category->getRequestPath(); // will return category URL
}
?>
Run Code Online (Sandbox Code Playgroud)
其他方式:
$children = Mage::getModel('catalog/category')->load(10)->getChildrenCategories();
foreach ($children as $category):
$category = Mage::getModel('catalog/category')->load($category->getId());
echo '<li><a href="' . $category->getUrl() . '">' . $category->getName() . '</a></li>';
endforeach;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
65518 次 |
| 最近记录: |