/** * {@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'); }