/** * {@inheritdoc} */ public function generateCondition(ConditionInterface $condition, QueryBuilder $query, ShopContextInterface $context) { if (!$query->hasState(self::STATE_INCLUDES_TOPSELLER_TABLE)) { $query->leftJoin('product', 's_articles_top_seller_ro', 'topSeller', 'topSeller.article_id = product.id'); $query->addState(self::STATE_INCLUDES_TOPSELLER_TABLE); } $query->andWhere('topSeller.sales > :sales'); /** @var SalesCondition $condition */ $query->setParameter('sales', $condition->getMinSales()); }