Exemplo n.º 1
0
 /**
  * @return number
  */
 private function getRange()
 {
     $maxPrice = $this->getMaxPriceInt();
     $index = 1;
     do {
         $range = pow(10, strlen(floor($maxPrice)) - $index);
         $items = $this->resource->getCount($range);
         $index++;
     } while ($range > self::MIN_RANGE_POWER && count($items) < 2);
     return $range;
 }
Exemplo n.º 2
0
 /**
  * Get information about products count in range
  *
  * @param   int $range
  * @return  int
  */
 public function getRangeItemCounts($range)
 {
     $items = array_key_exists($range, $this->rangeItemCounts) ? $this->rangeItemCounts[$range] : null;
     if ($items === null) {
         $items = $this->resource->getCount($range);
         // checking max number of intervals
         $i = 0;
         $lastIndex = null;
         $maxIntervalsNumber = $this->getRangeMaxIntervalsValue();
         $calculation = $this->getRangeCalculationValue();
         foreach ($items as $k => $v) {
             ++$i;
             if ($calculation == self::RANGE_CALCULATION_MANUAL && $i > 1 && $i > $maxIntervalsNumber) {
                 $items[$lastIndex] += $v;
                 unset($items[$k]);
             } else {
                 $lastIndex = $k;
             }
         }
         $this->rangeItemCounts[$range] = $items;
     }
     return $items;
 }