[英]Get products which exists in two categories
I need to find the products that exists in category 93 AND 97. So far i am able to get products that exists in category 93 OR 97, but no luck with AND instead. 我需要找到存在于类别93和97中的产品。到目前为止,我能够获得存在于类别93或97中的产品,但是使用AND却没有运气。
Im really clueless right now, and have done a lot of google search now. 我现在真的很笨,现在已经做了很多Google搜索。
Any help is appreciated! 任何帮助表示赞赏!
Code so far: 到目前为止的代码:
$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 Enterprise version 1.13.0.0 Magento Enterprise版本1.13.0.0
Take a look @ How to get products that are found in 2 or more categories 看看@ 如何获得2个或更多类别的产品
$collection = Mage::getModel('catalog/product')->getCollection();
....
$cat_ids = array(93,97);
$collection->addAttributeToFilter('category_id', array('in' => array('finset' => $cat_ids)))
Think the syntax maybe the problem. 认为语法可能是问题。 Try 尝试
$collection->addAttributeToFilter('category_id', array( 'in' => array(93,97))),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.