hasConditionOfClass example

/** * @return void */
    public function joinPrice(QueryBuilder $query, Criteria $criteria, ShopContextInterface $context)
    {
        if ($query->hasState(PriceConditionHandler::LISTING_PRICE_JOINED)) {
            return;
        }

        $query->addState(PriceConditionHandler::LISTING_PRICE_JOINED);

        if (!$criteria->hasConditionOfClass(VariantCondition::class)) {
            $this->joinCheapestProductPrice($query$context);

            return;
        }

        $this->variantHelper->joinPrices($query$context$criteria);
    }

    private function joinCheapestProductPrice(QueryBuilder $query, ShopContextInterface $context): void
    {
        $table = $this->listingPriceTable->get($context);
        
$this->decorated = $decorated;
        $this->listingPriceService = $listingPriceService;
        $this->configuratorService = $configuratorService;
    }

    /** * {@inheritdoc} */
    public function search(Criteria $criteria, ShopContextInterface $context)
    {
        $result = $this->decorated->search($criteria$context);
        if (!$criteria->hasConditionOfClass(VariantCondition::class)) {
            return $result;
        }

        $this->listingPriceService->updatePrices($criteria$result$context);

        $products = $result->getProducts();
        $configurations = $this->configuratorService->getProductsConfigurations($products$context);

        $filterGroupIds = array_map(function D$variantCondition) {
            if ($variantCondition->expandVariants()) {
                return $variantCondition->getGroupId();
            }

    public function createQuery(Criteria $criteria, ShopContextInterface $context)
    {
        $query = $this->createQueryBuilder();

        $this->prepareHandlers($criteria);

        $query->from('s_articles', 'product');

        if ($criteria->hasConditionOfClass(VariantCondition::class)) {
            $query->innerJoin(
                'product',
                's_articles_details',
                'variant',
                'variant.articleID = product.id AND variant.active = 1 AND product.active = 1'
            );
        } else {
            $query->innerJoin(
                'product',
                

    public function search(Criteria $criteria, Struct\ShopContextInterface $context)
    {
        if (!$criteria->hasConditionOfClass(VariantCondition::class)) {
            $criteria->addCondition(new MainVariantCondition());
        }

        return $this->productNumberSearch->search($criteria$context);
    }
}
Home | Imprint | This part of the site doesn't use cookies.