protected function _getSelect($filter) { $select = parent::_getSelect($filter); $fromPart = $select->getPart(Zend_Db_Select::FROM); if (!empty($fromPart['cat_index']['joinCondition'])) { $fromPart['cat_index']['joinCondition'] = str_replace('cat_index.visibility IN(2, 4)', 'cat_index.visibility IN(2, 3, 4)', $fromPart['cat_index']['joinCondition']); } $select->setPart(Zend_Db_Select::FROM, $fromPart); return $select; }
/** * Apply attribute filter to product collection * * @param Mage_Catalog_Model_Layer_Filter_Price $filter * @param int $range * @param int $index the range factor * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Layer_Filter_Attribute */ public function applyFilterToCollection($filter, $range, $index) { if (!Mage::helper('searchanise/ApiSe')->checkSearchaniseResult(true)) { return parent::applyFilterToCollection($filter, $range, $index); } $collection = $filter->getLayer()->getProductCollection(); if (!method_exists($collection, 'checkSearchaniseResult') || !$collection->checkSearchaniseResult()) { return parent::applyFilterToCollection($filter, $range, $index); } // Disable internal price filter. return $this; }
/** * Initialize connection and define main table name * */ protected function _construct() { parent::_construct(); }
public function getCount($filter, $range) { if (method_exists($this, '_getFullPriceExpression')) { $select = $this->_getSelect($filter); $priceExpression = $this->_getFullPriceExpression($filter, $select); /** * Check and set correct variable values to prevent SQL-injections */ $range = floatval($range); if ($range == 0) { $range = 1; } $countExpr = new Zend_Db_Expr('COUNT(distinct e.entity_id)'); $rangeExpr = new Zend_Db_Expr("FLOOR(({$priceExpression}) / {$range}) + 1"); $select->columns(array('range' => $rangeExpr, 'count' => $countExpr)); $select->group($rangeExpr)->order("{$rangeExpr} ASC"); return $this->_getReadAdapter()->fetchPairs($select); } else { return parent::getCount($filter, $range); } }