/**
  * {@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);
 }
 /**
  * Test for stats aggregation toArray() method.
  */
 public function testToArray()
 {
     $aggregation = new StatsAggregation('test_agg');
     $aggregation->setField('test_field');
     $expectedResult = ['agg_test_agg' => ['stats' => ['field' => 'test_field']]];
     $this->assertEquals($expectedResult, $aggregation->toArray());
 }
 /**
  * Tests if parameter can be passed to constructor.
  */
 public function testConstructor()
 {
     $aggregation = new StatsAggregation('foo', 'fieldValue', 'scriptValue');
     $this->assertSame(['stats' => ['field' => 'fieldValue', 'script' => 'scriptValue']], $aggregation->toArray());
 }
 public function handle(CriteriaPartInterface $criteriaPart, Criteria $criteria, Search $search, ShopContextInterface $context)
 {
     $statsAgg = new StatsAggregation('sales');
     $statsAgg->setField('sales');
     $search->addAggregation($statsAgg);
 }
 /**
  * {@inheritdoc}
  */
 public function handle(CriteriaPartInterface $criteriaPart, Criteria $criteria, Search $search, ShopContextInterface $context)
 {
     $aggregation = new StatsAggregation('vote_average');
     $aggregation->setField('voteAverage.average');
     $search->addAggregation($aggregation);
 }