コード例 #1
0
 /**
  * @param FacetInterface|Facet\PriceFacet $facet
  * @param Criteria $criteria
  * @param ShopContextInterface $context
  * @return ValueListFacetResult
  */
 public function generateFacet(FacetInterface $facet, Criteria $criteria, ShopContextInterface $context)
 {
     $queryCriteria = clone $criteria;
     $queryCriteria->resetConditions();
     $queryCriteria->resetSorting();
     $query = $this->queryBuilderFactory->createQuery($queryCriteria, $context);
     $query->resetQueryPart('groupBy');
     $query->resetQueryPart('orderBy');
     $query->groupBy('product.id');
     $query->select('DISTINCT product.supplierID as id');
     /**@var $statement \Doctrine\DBAL\Driver\ResultStatement */
     $statement = $query->execute();
     $ids = $statement->fetchAll(\PDO::FETCH_COLUMN);
     $ids = array_filter($ids);
     if (empty($ids)) {
         return null;
     }
     $manufacturers = $this->manufacturerService->getList($ids, $context);
     $activeManufacturers = $this->getActiveIds($criteria);
     return $this->createFacetResult($manufacturers, $activeManufacturers);
 }
コード例 #2
0
 /**
  * @param $buckets
  * @param ShopContextInterface $context
  * @return \Shopware\Bundle\StoreFrontBundle\Struct\Product\Manufacturer[]
  * @throws \Exception
  */
 private function getManufacturers($buckets, ShopContextInterface $context)
 {
     $ids = array_column($buckets, 'key');
     $manufacturers = $this->manufacturerService->getList($ids, $context);
     return $manufacturers;
 }