Skip to content

Product attribute aggregations

Product attribute aggregations aggregate search results by the value of the product's attributes.

Depending on attribute type, the following aggregations are available:

  • ProductAttributeBooleanAggregation
  • ProductAttributeColorAggregation
  • ProductAttributeFloatAggregation
  • ProductAttributeFloatRangeAggregation
  • ProductAttributeIntegerAggregation
  • ProductAttributeIntegerRangeAggregation
  • ProductAttributeSelectionAggregation

Arguments

  • name - name of the Aggregation
  • attributeDefinitionIdentifier - identifier of the attribute

Range aggregations (ProductAttributeFloatRangeAggregation and ProductAttributeIntegerRangeAggregation) additionally take:

  • ranges - array of Range objects that define the borders of the specific range sets

Example

1
2
3
4
5
6
7
use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery;
use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Aggregation\AttributeSelectionTermAggregation;

$query = new ProductQuery();
$query->setAggregations([
    new AttributeSelectionTermAggregation('skin', 'skin_type'),
]);
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range;
use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery;
use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Aggregation\AttributeIntegerRangeAggregation;

$query = new ProductQuery();
$query->setAggregations([
    new AttributeIntegerRangeAggregation('buttons', 'number_of_buttons', [
        Range::ofInt(null, 5),
        Range::ofInt(5, 10),
        Range::ofInt(10, null),
    ]),
]);