php – 获取孩子类别magento

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 获取孩子类别magento脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
试图让一个活跃的特定类别的孩子.请帮忙.我无法做到一点我目前能够显示他们,但没有具体.感谢任何帮助.
$category = Mage::getModel('cataLOG/category')->load(2);
$category->getChildCategories();
$tree = $category->getTreeModel();
$tree->load();
$ids = $tree->getCollection()->getAllIds();
这里是加载活动类别的代码
/* Load category by id*/
$cat = Mage::getModel('catalog/category')->load($id);


/*Returns comma separated ids*/
$subcats = $cat->getChildren();

//PRint out categories string
#print_r($subcats);

foreach(explode(',',$subcats) as $subCatid)
{
  $_category = Mage::getModel('catalog/category')->load($subCatid);
  if($_category->getIsActive())
  {
    $caturl     = $_category->getURL();
    $catname     = $_category->getName();
    if($_category->getImageUrl())
    {
      $catimg     = $_category->getImageUrl();
    }
    echo '<h2><a href="'.$caturl.'" tITle="View the products for this category"><img src="'.$catimg.'" alt="" />'.$catname.'</a></h2>';
  }
}
?>

希望这可以帮助你.

脚本宝典总结

以上是脚本宝典为你收集整理的php – 获取孩子类别magento全部内容,希望文章能够帮你解决php – 获取孩子类别magento所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。