두 가지 범주의 제품을 찾으려고합니다. category1 또는 category2에있는 제품을 얻는 예제를 발견했습니다. http://www.alphadigital.cl/blog/lang/en-us/magento-filter-by-multiple-categories.html 나는 category1과 category2에있는 제품이 필요합니다.Magento의 두 가지 범주로 제품 컬렉션 필터링
블로그의 예는 다음과 같습니다 나 혼자이 필터를 사용하고 때
class ModuleName_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
extends Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection{
public function addCategoriesFilter($categories){
$alias = 'cat_index';
$categoryCondition = $this->getConnection()->quoteInto(
$alias.'.product_id=e.entity_id AND '.$alias.'.store_id=? AND ',
$this->getStoreId()
);
$categoryCondition.= $alias.'.category_id IN ('.$categories.')';
$this->getSelect()->joinInner(
array($alias => $this->getTable('catalog/category_product_index')),
$categoryCondition,
array('position'=>'position')
);
$this->_categoryIndexJoined = true;
$this->_joinFields['position'] = array('table'=>$alias, 'field'=>'position');
return $this;
}
}
이 수행 또는 쿼리 여러 카테고리를. 이 필터를 Mage_Catalog_Model_Layer의 prepareProductCollection 과 결합하면 어떻게 든 필터 효과가 제거됩니다.
어떻게 필터를 AND로 변경하고 prepareProductCollection과 결합 할 수 있습니까? 두 제품 컬렉션
감사
감사
위대한 솔루션과 설명, 감사합니다. – gregdev