/** * {@inheritdoc} */ public function handle(CriteriaPartInterface $criteriaPart, Criteria $criteria, Search $search, ShopContextInterface $context) { /** @var PriceSorting $criteriaPart */ $field = $this->fieldMapping->getPriceField($context); $sort = new FieldSort($field, strtolower($criteriaPart->getDirection())); $search->addSort($sort); }
/** * {@inheritdoc} */ public function handle(CriteriaPartInterface $criteriaPart, Criteria $criteria, Search $search, ShopContextInterface $context) { $aggregation = new StatsAggregation('price'); $field = $this->fieldMapping->getPriceField($context); $aggregation->setField($field); $search->addAggregation($aggregation); }
/** * {@inheritdoc} */ public function handle(CriteriaPartInterface $criteriaPart, Criteria $criteria, Search $search, ShopContextInterface $context) { $field = $this->fieldMapping->getPriceField($context); $range = []; /** @var PriceCondition $criteriaPart */ if ($criteriaPart->getMinPrice()) { $range['gte'] = $criteriaPart->getMinPrice(); } if ($criteriaPart->getMaxPrice()) { $range['lte'] = $criteriaPart->getMaxPrice(); } $filter = new RangeFilter($field, $range); if ($criteria->hasBaseCondition($criteriaPart->getName())) { $search->addFilter($filter); } else { $search->addPostFilter($filter); } }