addFacet() public method

Append a facet to the collection
public addFacet ( string $field, string $facetType, array $facetConfig, array $facetFilter = null ) : Collection
$field string Facet field.
$facetType string Facet type.
$facetConfig array Facet config params.
$facetFilter array Facet filter.
return Collection
Example #1
0
 /**
  * Append facets used to select suggested attributes.
  *
  * @return \Smile\ElasticsuiteCatalog\Model\Autocomplete\Product\Attribute\DataProvider
  */
 private function prepareProductCollection()
 {
     foreach ($this->attributeCollection as $attribute) {
         $facetSize = $this->getResultsPageSize();
         $filterField = $this->getFilterField($attribute);
         $this->productCollection->addFacet($filterField, BucketInterface::TYPE_TERM, ['size' => $facetSize]);
     }
     return $this;
 }