/** * Apply price range filter to product collection * * @param Mage_Catalog_Model_Layer_Filter_Price $filter Filter * @return Mage_Catalog_Model_Resource_Layer_Filter_Price */ public function applyPriceRange($filter) { $intervals = $filter->getPriorIntervals(); if (!$intervals) { return $this; } $select = $filter->getLayer()->getProductCollection()->getSelect(); $priceExpr = $this->_getPriceExpression($filter, $select, false); $whereArray = array(); foreach ($intervals as $interval) { list($from, $to) = $interval; if ($from === '' && $to === '') { return $this; } if ($to !== '') { $to = (double) $to; if ($from == $to) { $to += self::MIN_POSSIBLE_PRICE; } } if ($from !== '' && $to !== '') { $whereArray[] = "({$priceExpr} >= {$this->_getComparingValue($from, $filter)} AND {$priceExpr} <= " . "{$this->_getComparingValue($to, $filter, false)})"; } else { if ($from !== '') { $whereArray[] = "({$priceExpr} >= {$this->_getComparingValue($from, $filter)})"; } if ($to !== '') { $whereArray[] = "({$priceExpr} <= {$this->_getComparingValue($to, $filter, false)})"; } } } $select->where(new Zend_db_Expr(implode(' OR ', $whereArray))); return $this; }