Author: Aurelien FOUCRET (aurelien.foucret@smile.fr)
Inheritance: extends Magento\Catalog\Model\ResourceModel\Product\Collection
Beispiel #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;
 }
Beispiel #2
0
 /**
  * Init suggested products collection.
  * Returns null if no suggested search terms.
  *
  * @return \Smile\ElasticsuiteCatalog\Model\Autocomplete\Product
  */
 private function prepareProductCollection()
 {
     $terms = $this->getQueryText();
     $this->productCollection->addSearchFilter($terms);
     $this->productCollection->setPageSize($this->getResultsPageSize());
     $this->productCollection->addAttributeToSelect('name')->addAttributeToSelect('thumbnail')->addPriceData();
     if (!$this->configurationHelper->isShowOutOfStock()) {
         $this->productCollection->addIsInStockFilter();
     }
     return $this;
 }