我试图从多个类别获取产品,我使用从多个类别获取产品
$category_collection = Mage::getModel('catalog/category')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('name', array('like' => '%'.$searchstring.'%'))
->load();
foreach ($category_collection as $category) {
$ids[] = $category->getId();
}
$collection = Mage::getModel('catalog/product')
->getCollection()
->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
->addAttributeToFilter('category_id', array('in' => array('finset' => $ids)))
->addAttributeToSelect('*')
->setPageSize(5);
,但它显示错误Item (Mage_Catalog_Model_Product) with the same id "2" already exist
请帮助我获得不同的集合。
你过滤CATEGORY_ID通过提供产品ID。 –
不,我从类别ID阵列过滤产品 –
嗯,你好像已经更新了代码。 –