Пример #1
0
 /**
  * Get maximum price from layer products set
  *
  * @param EntityStorage $entityStorage
  * @return float
  */
 private function getMaxPriceInt(EntityStorage $entityStorage)
 {
     $aggregations = $this->dataProvider->getAggregations($entityStorage);
     $maxPrice = $aggregations['max'];
     $maxPrice = floor($maxPrice);
     return $maxPrice;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function getItems(BucketInterface $bucket, array $dimensions, \Magento\Framework\Search\Dynamic\EntityStorage $entityStorage)
 {
     $aggregations = $this->dataProvider->getAggregations($entityStorage);
     $options = $this->options->get();
     if ($aggregations['count'] < $options['interval_division_limit']) {
         return [];
     }
     $this->algorithm->setStatistics($aggregations['min'], $aggregations['max'], $aggregations['std'], $aggregations['count']);
     $this->algorithm->setLimits($aggregations['min'], $aggregations['max'] + 0.01);
     $interval = $this->dataProvider->getInterval($bucket, $dimensions, $entityStorage);
     $data = $this->algorithm->calculateSeparators($interval);
     $data[0]['from'] = '';
     // We should not calculate min and max value
     $data[count($data) - 1]['to'] = '';
     $dataSize = count($data);
     for ($key = 0; $key < $dataSize; $key++) {
         if (isset($data[$key + 1])) {
             $data[$key]['to'] = $data[$key + 1]['from'];
         }
     }
     return $data;
 }