Magento 产品集合:排除特定类别的产品
*$parent_category*有N个子类别。除了属于*$excluded\u child\u category*的产品外,我如何从*$parent\u category*获取所有产品 以下是检索父类别的方法:Magento 产品集合:排除特定类别的产品,magento,magento-1.7,Magento,Magento 1.7,*$parent_category*有N个子类别。除了属于*$excluded\u child\u category*的产品外,我如何从*$parent\u category*获取所有产品 以下是检索父类别的方法: $collection = Mage::getModel( 'catalog/category' )->load( $parent_category_id )->getProductCollection(); 你应该试试这样的 Mage::getModel( 'cata
$collection = Mage::getModel( 'catalog/category' )->load( $parent_category_id )->getProductCollection();
你应该试试这样的
Mage::getModel( 'catalog/category' )->load( $parent_category_id )->getProductCollection()->addFieldToFilter('entity_id', array('nin' => array('your category id')));
你应该试试这样的
Mage::getModel( 'catalog/category' )->load( $parent_category_id )->getProductCollection()->addFieldToFilter('entity_id', array('nin' => array('your category id')));
你试过这个吗?似乎对我不起作用,抛出一个错误:
致命错误:在app/code/core/Mage/Eav/Model/Entity/Abstract.php第816行的非对象上调用成员函数getBackend()
是否启用了平面类别?我已更改代码,我没有尝试过这个,而您得到的错误是因为没有像“category\u id”这样的属性,所以我更改了条件。您尝试过这个吗?似乎对我不起作用,抛出一个错误:致命错误:在app/code/core/Mage/Eav/Model/Entity/Abstract.php第816行的非对象上调用成员函数getBackend()
是否启用了平面类别?我已更改代码,我并没有尝试过这个方法,你们得到的错误是因为并没有像“category_id”这样的属性,所以我改变了条件