joinVariantCondition example

'(variant.laststock * variant.instock) >= (variant.laststock * variant.minpurchase)'
        );

        /* * Query to get the id of the cheapest price */
        $cheapestPriceIdQuery = $this->connection->createQueryBuilder();

        $joinCondition = ' cheapestPrices.articleID = details.articleID ';
        foreach ($criteria->getConditionsByClass(VariantCondition::class) as $condition) {
            if ($condition->expandVariants()) {
                $joinCondition = $this->joinVariantCondition($mainQuery$cheapestPriceIdQuery$cheapestPriceQuery$condition) . $joinCondition;
            }
        }

        /* * Last graduation configuration only needs to use for the cheapest price, not for the different price count. * Get the cheapest price of the fallback customer group, if no price of the current customer group is available. */
        $countSubQuery = clone $cheapestPriceQuery;
        $graduation = 'IF(prices.id IS NOT NULL, prices.from = 1, defaultPrices.from = 1)';
        if ($this->config->get('useLastGraduationForCheapestPrice')) {
            $graduation = "CASE WHEN prices.id IS NOT NULL THEN (IF(priceGroup.id IS NOT NULL, prices.from = 1, prices.to = 'beliebig')) ELSE (IF(priceGroup.id IS NOT NULL, defaultPrices.from = 1, defaultPrices.to = 'beliebig')) END";
return $condition instanceof VariantCondition;
    }

    /** * {@inheritdoc} */
    public function generateCondition(
        ConditionInterface $condition,
        QueryBuilder $query,
        ShopContextInterface $context
    ) {
        $this->helper->joinVariantCondition($query$condition);
    }
}
return;
        }

        $variantCondition = [
            'listing_price.product_id = variant.articleId',
        ];

        $conditions = $criteria->getConditionsByClass(VariantCondition::class);
        /** @var VariantCondition $condition */
        foreach ($conditions as $condition) {
            if ($condition->expandVariants()) {
                $this->joinVariantCondition($query$condition);

                $tableKey = $condition->getName();
                $variantCondition[] = 'listing_price.' . $tableKey . '_id = ' . $tableKey . '.option_id';
            }
        }

        $priceTable = $this->createListingPriceTable($criteria$context);

        $query->addSelect('listing_price.*');
        $query->leftJoin('variant', '(' . $priceTable->getSQL() . ')', 'listing_price', implode(' AND ', $variantCondition));

        
Home | Imprint | This part of the site doesn't use cookies.