`
coolsooner
  • 浏览: 1311083 次
文章分类
社区版块
存档分类
最新评论

magento获取指定目录分类的子分类

 
阅读更多

magento获取指定目录分类的子分类

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
if ( $category ->hasChildren()) { //判断是否有子目录
$ids = $category ->getChildren(); //提取子目录id清单
$subCategories = Mage::getModel( 'catalog/category' )->getCollection();
$subCategories ->getSelect()->where( "e.entity_id in ($ids)" ); //提取指定目录ids的上当清单
$subCategories ->addAttributeToSelect( 'name' ); //指定查找目录名称
$subCategories ->load();
foreach ( $subCategories AS $item ) {
echo " - " ;
echo '<a href="' . $item ->getUrl() . '">' ; //获取目录链接
echo $item ->getName(); //获取目录名
echo "</a>(" ;
echo $item ->getProductCount(); //获取目录下的产品数量
//echo $item->getChildrenCount(); //获取目录下子目录数量
echo ")" ;
echo "<br/>" ;
}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics