0

我需要找到存在于类别 93 和 97 中的产品。到目前为止,我能够获得存在于类别 93 或 97 中的产品,但使用 AND 却没有运气。

我现在真的一无所知,现在已经做了很多谷歌搜索。

任何帮助表示赞赏!

到目前为止的代码:

$collection = Mage::getModel('catalog/product')->getCollection(); 
        $collection->distinct(true); 
        $collection->joinField('category_id', 
        'catalog/category_product', 
        'category_id', 
        'product_id=entity_id', 
        null, 
        'left'); 
        $collection->addAttributeToFilter('category_id', array( 'in' =>
        array('finset'=> '93'),
        array('finset'=> '97')));

Magento 企业版 1.13.0.0

4

2 回答 2

1

看看@如何获得在 2 个或更多类别中找到的产品

$collection = Mage::getModel('catalog/product')->getCollection(); 
....
$cat_ids = array(93,97);  
$collection->addAttributeToFilter('category_id', array('in' => array('finset' => $cat_ids)))
于 2013-12-06T17:08:25.693 回答
0

认为语法可能是问题所在。尝试

$collection->addAttributeToFilter('category_id', array( 'in' => array(93,97))),
于 2013-12-06T17:12:46.817 回答