我正在尝试获取通过 magento 管理端添加的所有子类别。从获取的类别中,我想排除一个类别 ID。下面提供的是我用来获取所有子类别的代码
<?php
$allCategories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('level',2)
->addIsActiveFilter();
?>
请让我知道排除类别 ID 69 并显示级别 2 的所有其他类别。
最佳答案
请尝试下面的代码,
<?php
$allCategories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('level',2)
->addAttributeToFilter('entity_id', array('nin' => 69))
->addIsActiveFilter();
?>
如果有任何疑问,请告诉我
谢谢
关于php - 从 magento 中的类别集合中排除类别 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32708155/