/** * Filter the collection by an EAV attribute option * * @param $products * @param Mage_Eav_Model_Entity_Attribute $attribute * @param int|array $value * @param Fishpig_AttributeSplashPro_Model_Page $page * @param string $cond * @return $this */ protected function _addEavAttributeOptionFilterToProductCollection($products, $attribute, $value, $page, $cond = '= ?') { $alias = $attribute->getAttributeCode() . '_index'; if (!is_array($value)) { $alias .= '_' . $value; } $products->getSelect()->distinct()->join(array($alias => $this->getTable('catalog/product_index_eav')), "`{$alias}`.`entity_id` = `e`.`entity_id`" . $this->_getReadAdapter()->quoteInto(" AND `{$alias}`.`attribute_id` = ? ", $attribute->getAttributeId()) . $this->_getReadAdapter()->quoteInto(" AND `{$alias}`.`store_id` = ? ", $page->getStoreId()) . $this->_getReadAdapter()->quoteInto(" AND `{$alias}`.`value` " . $cond, $value), ''); return $this; }