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/>" ;
  }
  }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
  • 2021-07-03
猜你喜欢
  • 2021-12-15
  • 2022-12-23
  • 2021-10-23
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案