脚本宝典收集整理的这篇文章主要介绍了php – 在Magento中获取所有类别的数组,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
$massage_cats=array( array("entITy_id"=>78,"name"=>"Massage Oils and Tools","url_key"=>"massage-oils-and-tools","url_path"=>"essential-accessories/massage-oils-and-tools.htML"),array("entity_id"=>79,"name"=>"Massage Oils","url_key"=>"massage-oils","url_path"=>"essential-accessories/massage-oils-and-tools/massage-oils.html") );
所以我想说出类似的东西
$massage_cats= array(); $allcats = Mage::getModel('cataLOG/cats?')->loadAll(); foreach($allcats $k=>$item){ array_push($massage_cats,$item->loadDetails()); }
$categories = Mage::getModel('catalog/category')->getCollection() ->addAttributeToSelect('id') ->addAttributeToSelect('name') ->addAttributeToSelect('url_key') ->addAttributeToSelect('url') ->addAttributeToSelect('is_active'); foreach ($categories as $category) { if ($category->getIsActive()) { // Only pull Active categories $entity_id = $category->getId(); $name = $category->getName(); $url_key = $category->getUrlKey(); $url_path = $category->getUrl(); } }
编辑
我在MagentoCommerce.com的帖子中对此进行了调整.您可以使用此代码:
$category = Mage::getModel('catalog/category'); $tree = $category->getTreeModel(); $tree->load(); $ids = $tree->getCollection()->getAllIds(); if ($ids){ foreach ($ids as $id){ $cat = Mage::getModel('catalog/category'); $cat->load($id); $entity_id = $cat->getId(); $name = $cat->getName(); $url_key = $cat->getUrlKey(); $url_path = $cat->getUrlPath(); } }
以上是脚本宝典为你收集整理的php – 在Magento中获取所有类别的数组全部内容,希望文章能够帮你解决php – 在Magento中获取所有类别的数组所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。