Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento 产品集合:排除特定类别的产品_Magento_Magento 1.7 - Fatal编程技术网

Magento 产品集合:排除特定类别的产品

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

*$parent_category*有N个子类别。除了属于*$excluded\u child\u category*的产品外,我如何从*$parent\u category*获取所有产品

以下是检索父类别的方法:

$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”这样的属性,所以我改变了条件