根据分类属性来获取目录

来源:互联网 发布:苹果屏幕录制软件 编辑:程序博客网 时间:2024/05/05 08:35
* 根据分类属性来获取目录根据分类属性来获取目录2010-09-03 15:06:06.0有60人喜欢这篇文章magento中获取分类还是比较简单的1.根据分类的ID来获取view sourceprint?1Mage::getModel('catalog/category')->load('分类ID')2.根据分类的属性来获取分类view sourceprint?1Mage::getModel('catalog/category')->loadByAttribute('name','栏目名');我们看下方法名就知道了可以用任何属性来查找当前分类..通过栏目的url来来获取分类view sourceprint?1Mage::getModel('catalog/category')->loadByAttribute('url_key', 'the-key-goes-here');获取子分类中的方法,看我以前的文章:magento获取子分类为了实现magento根据分类或者栏目的属性来获取分类or栏目.在获取该分类或者目录下的所有子分类我们可以根据上面的loadByAttribute来获取父分类,再根据前面我的文章来获取所有的子分类最终代码view sourceprint?01loadByAttribute('name','选购礼盒');04if($pc->hasChildren()) {05$ids = $pc->getChildren();06$subCategories = Mage::getModel('catalog/category')->getCollection();07$subCategories->getSelect()->where("e.entity_id in ($ids)");08$subCategories->addAttributeToSelect('*');09$subCategories->load();10}11?>再循环打印出分类的别名和url,这里我是利用了分类的描述这个属性view sourceprint?12
  • getUrl();?>">
  • 3