dongxu7408 2015-09-22 04:05
浏览 44
已采纳

从magento中的类别集合中排除类别ID

I am trying to fetch all the sub categories added via admin side of magento. From the categories fetched I would like to exclude one category id. Below provided is the code which I have used to fetch all the sub category

<?php
      $allCategories = Mage::getModel('catalog/category')
                       ->getCollection()
                       ->addAttributeToSelect('*')
                       ->addAttributeToFilter('level',2)
                       ->addIsActiveFilter(); 
?>

Please let me know to exclude category id 69 and display all other category of level 2.

  • 写回答

1条回答 默认 最新

  • dtef9322 2015-09-22 04:58
    关注

    Please try the bellow code,

    <?php
          $allCategories = Mage::getModel('catalog/category')
                           ->getCollection()
                           ->addAttributeToSelect('*')
                           ->addAttributeToFilter('level',2)
                           ->addAttributeToFilter('entity_id', array('nin' => 69))
                           ->addIsActiveFilter(); 
    
    ?>
    

    Let me know if you have any query

    Thanks

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?