Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function generateSorting(SortingInterface $sorting, QueryBuilder $query, ShopContextInterface $context)
 {
     $selection = $this->priceHelper->getSelection($context);
     $this->priceHelper->joinPrices($query, $context);
     $query->addSelect('MIN(' . $selection . ') as cheapest_price');
     /** @var PriceSorting $sorting */
     $query->addOrderBy('cheapest_price', $sorting->getDirection())->addOrderBy('product.id', $sorting->getDirection());
 }
Exemplo n.º 2
0
 /**
  * @param FacetInterface|Facet\PriceFacet $facet
  * @param Criteria $criteria
  * @param ShopContextInterface $context
  * @return RangeFacetResult
  */
 public function generateFacet(FacetInterface $facet, Criteria $criteria, ShopContextInterface $context)
 {
     $queryCriteria = clone $criteria;
     $queryCriteria->resetConditions();
     $queryCriteria->resetSorting();
     $query = $this->queryBuilderFactory->createQuery($queryCriteria, $context);
     $query->resetQueryPart('orderBy');
     $query->resetQueryPart('groupBy');
     $selection = $this->priceHelper->getSelection($context);
     $this->priceHelper->joinPrices($query, $context);
     $query->select('MIN(' . $selection . ') as cheapest_price');
     /**@var $statement \Doctrine\DBAL\Driver\ResultStatement */
     $statement = $query->execute();
     $min = $statement->fetch(\PDO::FETCH_COLUMN);
     $query->groupBy('product.id')->orderBy('cheapest_price', 'DESC')->setFirstResult(0)->setMaxResults(1);
     /**@var $statement \Doctrine\DBAL\Driver\ResultStatement */
     $statement = $query->execute();
     $max = $statement->fetch(\PDO::FETCH_COLUMN);
     $activeMin = $min;
     $activeMax = $max;
     /**@var $condition PriceCondition */
     if ($condition = $criteria->getCondition($facet->getName())) {
         $activeMin = $condition->getMinPrice();
         $activeMax = $condition->getMaxPrice();
     }
     return new RangeFacetResult($facet->getName(), $criteria->hasCondition($facet->getName()), $this->snippetNamespace->get($facet->getName(), 'Price'), (double) $min, (double) $max, (double) $activeMin, (double) $activeMax, $this->minFieldName, $this->maxFieldName, [], 'frontend/listing/filter/facet-currency-range.tpl');
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function generateCondition(ConditionInterface $condition, QueryBuilder $query, ShopContextInterface $context)
 {
     $selection = $this->priceHelper->getSelection($context);
     $selection = 'MIN(' . $selection . ')';
     $this->priceHelper->joinPrices($query, $context);
     /** @var PriceCondition $condition */
     if ($condition->getMaxPrice() > 0 && $condition->getMinPrice() > 0) {
         $query->andHaving($selection . ' BETWEEN :priceMin AND :priceMax');
         $query->setParameter(':priceMin', $condition->getMinPrice());
         $query->setParameter(':priceMax', $condition->getMaxPrice());
     } elseif ($condition->getMaxPrice() > 0) {
         $query->andHaving($selection . ' <= :priceMax');
         $query->setParameter(':priceMax', $condition->getMaxPrice());
     } elseif ($condition->getMinPrice() > 0) {
         $query->andHaving($selection . ' >= :priceMin');
         $query->setParameter(':priceMin', $condition->getMinPrice());
     }
     return;
 }
 /**
  * {@inheritdoc}
  */
 public function generateCondition(ConditionInterface $condition, QueryBuilder $query, ShopContextInterface $context)
 {
     $this->priceHelper->joinPrices($query, $context);
     $query->andWhere('IFNULL(customerPrice.pseudoprice, defaultPrice.pseudoprice) > 0');
 }
 /**
  * {@inheritdoc}
  */
 public function generateCondition(ConditionInterface $condition, QueryBuilder $query, ShopContextInterface $context)
 {
     $this->priceHelper->joinAvailableVariant($query);
 }