脚本宝典收集整理的这篇文章主要介绍了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,请注明来意。