/** * {@inheritdoc} */ public function handle(CriteriaPartInterface $criteriaPart, Criteria $criteria, Search $search, ShopContextInterface $context) { /** @var ProductAttributeFacet $criteriaPart */ $field = 'attributes.core.' . $criteriaPart->getField(); $this->criteriaParts[] = $criteriaPart; switch ($criteriaPart->getMode()) { case ProductAttributeFacet::MODE_VALUE_LIST_RESULT: case ProductAttributeFacet::MODE_RADIO_LIST_RESULT: $aggregation = new TermsAggregation($criteriaPart->getName()); $aggregation->setField($field); break; case ProductAttributeFacet::MODE_BOOLEAN_RESULT: $count = new ValueCountAggregation($criteriaPart->getName() . '_count'); $count->setField($field); $aggregation = new FilterAggregation($criteriaPart->getName()); $aggregation->setFilter(new ExistsFilter($field)); $aggregation->addAggregation($count); break; case ProductAttributeFacet::MODE_RANGE_RESULT: $aggregation = new TermsAggregation($criteriaPart->getName()); $aggregation->setField($field); break; default: return; } $search->addAggregation($aggregation); }
/** * {@inheritdoc} */ public function handle(CriteriaPartInterface $criteriaPart, Criteria $criteria, Search $search, ShopContextInterface $context) { $aggregation = new ValueCountAggregation('has_available_variant_count'); $aggregation->setField('hasAvailableVariant'); $filter = new FilterAggregation('has_available_variant_filter'); $filter->setFilter(new TermFilter('hasAvailableVariant', 1)); $filter->addAggregation($aggregation); $search->addAggregation($filter); }
/** * {@inheritdoc} */ public function handle(CriteriaPartInterface $criteriaPart, Criteria $criteria, Search $search, ShopContextInterface $context) { $aggregation = new ValueCountAggregation('shipping_free_count'); $aggregation->setField('shippingFree'); $filterAgg = new FilterAggregation('shipping_free_filter'); $filterAgg->setFilter(new TermFilter('shippingFree', 1)); $filterAgg->addAggregation($aggregation); $search->addAggregation($filterAgg); }