/**
  * {@inheritdoc}
  */
 public function generateCondition(ConditionInterface $condition, QueryBuilder $query, ShopContextInterface $context)
 {
     $ids = $condition->getProductVariantIds();
     if (!$ids) {
         return;
     }
     $query->innerJoin('product', 's_articles_details', 'variantFilterArticleDetails', 'variantFilterArticleDetails.articleID = product.id');
     foreach ($ids as $groupId => $variantOptions) {
         $tableAlias = 'variantFilterArticleDetails' . $groupId;
         $paramAlias = ':options' . $groupId;
         $query->innerJoin('variantFilterArticleDetails', 's_article_configurator_option_relations', $tableAlias, 'variantFilterArticleDetails.id = ' . $tableAlias . '.article_id AND ' . $tableAlias . '.option_id IN (' . $paramAlias . ')')->setParameter($paramAlias, $variantOptions, Connection::PARAM_INT_ARRAY);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function generateCondition(ConditionInterface $condition, QueryBuilder $query, ShopContextInterface $context)
 {
     $query->innerJoin('product', 's_articles_details', 'allVariants', 'allVariants.articleID = product.id
          AND allVariants.active = 1
          AND allVariants.instock >= allVariants.minpurchase');
     $query->addState(self::STATE_INCLUDES_ALL_VARIANTS);
 }
Esempio n. 3
0
 /**
  * @inheritdoc
  */
 public function generateCondition(ConditionInterface $condition, QueryBuilder $query, ShopContextInterface $context)
 {
     if (!$query->hasState(self::STATE_ESD_INCLUDED)) {
         $query->innerJoin('product', 's_articles_esd', 'esd', 'esd.articleID = product.id');
         $query->addState(self::STATE_ESD_INCLUDED);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function generateCondition(ConditionInterface $condition, QueryBuilder $query, ShopContextInterface $context)
 {
     $query->innerJoin('product', 's_articles_supplier', 'manufacturer', 'manufacturer.id = product.supplierID
          AND product.supplierID IN (:manufacturer)');
     /** @var ManufacturerCondition $condition */
     $query->setParameter(':manufacturer', $condition->getManufacturerIds(), Connection::PARAM_INT_ARRAY);
 }
 /**
  * {@inheritdoc}
  */
 public function generateCondition(ConditionInterface $condition, QueryBuilder $query, ShopContextInterface $context)
 {
     if ($this->counter++ === 0) {
         $suffix = '';
     } else {
         $suffix = $this->counter;
     }
     $query->innerJoin('product', 's_articles_categories_ro', "productCategory{$suffix}", "productCategory{$suffix}.articleID = product.id\n            AND productCategory{$suffix}.categoryID IN (:category{$suffix})");
     /** @var CategoryCondition $condition */
     $query->setParameter(":category{$suffix}", $condition->getCategoryIds(), Connection::PARAM_INT_ARRAY);
 }
    /**
     * {@inheritdoc}
     */
    public function generateCondition(ConditionInterface $condition, QueryBuilder $query, ShopContextInterface $context)
    {
        $table = '
SELECT SUM(vote.points) / COUNT(vote.id) AS average, vote.articleID AS product_id
FROM s_articles_vote vote
GROUP BY vote.articleID';
        $query->innerJoin('product', '(' . $table . ')', 'voteAverage', 'voteAverage.product_id = product.id
             AND voteAverage.average >= :average');
        /** @var VoteAverageCondition $condition */
        $query->setParameter(':average', (double) $condition->getAverage());
        $query->addSelect('voteAverage.average');
        $query->addState(VoteAverageCondition::STATE_INCLUDES_VOTE_TABLE);
    }
 /**
  * {@inheritdoc}
  */
 public function generateCondition(ConditionInterface $condition, QueryBuilder $query, ShopContextInterface $context)
 {
     $tableKey = $condition->getName();
     $where = [];
     /** @var PropertyCondition $condition */
     foreach ($condition->getValueIds() as $valueId) {
         $valueKey = $tableKey . '_' . $valueId;
         $where[] = $tableKey . '.valueID = :' . $valueKey;
         $query->setParameter(':' . $valueKey, $valueId);
     }
     $where = implode(' OR ', $where);
     $query->innerJoin('product', 's_filter_articles', $tableKey, 'product.id = ' . $tableKey . '.articleID
          AND (' . $where . ')');
 }
 /**
  * {@inheritdoc}
  */
 public function generateCondition(ConditionInterface $condition, QueryBuilder $query, ShopContextInterface $context)
 {
     /** @var SearchTermCondition $condition */
     $searchQuery = $this->searchTermQueryBuilder->buildQuery($condition->getTerm());
     //no matching products found by the search query builder.
     //add condition that the result contains no product.
     if ($searchQuery == null) {
         $query->andWhere('0 = 1');
         return;
     }
     $queryString = $searchQuery->getSQL();
     $query->addSelect('searchTable.*');
     $query->addState(self::STATE_INCLUDES_RANKING);
     $query->innerJoin('product', '(' . $queryString . ')', 'searchTable', 'searchTable.product_id = product.id');
 }
Esempio n. 9
0
 /**
  * @inheritdoc
  */
 public function joinAvailableVariant(QueryBuilder $query)
 {
     if ($query->hasState(self::STATE_INCLUDES_AVAILABLE_VARIANT)) {
         return;
     }
     $stockCondition = '';
     if ($this->config->get('hideNoInstock')) {
         $stockCondition = 'AND (product.laststock * availableVariant.instock) >= (product.laststock * availableVariant.minpurchase)';
     }
     $query->innerJoin('product', 's_articles_details', 'availableVariant', 'availableVariant.articleID = product.id
          AND availableVariant.active = 1 ' . $stockCondition);
     $query->addState(self::STATE_INCLUDES_AVAILABLE_VARIANT);
 }
Esempio n. 10
0
 /**
  * @param QueryBuilder $query
  */
 private function rebuildQuery(QueryBuilder $query)
 {
     $query->resetQueryPart('orderBy');
     $query->resetQueryPart('groupBy');
     $query->innerJoin('product', 's_filter_articles', 'productProperty', 'productProperty.articleID = product.id');
     $query->groupBy('productProperty.valueID');
     $query->select('productProperty.valueID as id');
 }