joinVariants example

private function getFacet(
        ImmediateDeliveryFacet $facet,
        Criteria $reverted,
        Criteria $criteria,
        ShopContextInterface $context
    ): ?BooleanFacetResult {
        $query = $this->queryBuilderFactory->createQuery($reverted$context);
        $query->resetQueryPart('orderBy');
        $query->resetQueryPart('groupBy');

        $this->variantHelper->joinVariants($query);
        if (!$query->hasState(ImmediateDeliveryConditionHandler::STATE_INCLUDES_IMMEDIATE_DELIVERY_VARIANTS)) {
            $query->andWhere('allVariants.instock >= allVariants.minpurchase');
            $query->addState(ImmediateDeliveryConditionHandler::STATE_INCLUDES_IMMEDIATE_DELIVERY_VARIANTS);
        }

        $query->select('product.id')
            ->setMaxResults(1);

        $total = $query->execute()->fetch(PDO::FETCH_COLUMN);

        if ($total <= 0) {
            
public function generateCondition(
        ConditionInterface $condition,
        QueryBuilder $query,
        ShopContextInterface $context
    ) {
        $this->addCondition($condition$query);
    }

    private function addCondition(WidthCondition $condition, QueryBuilder $query): void
    {
        $this->variantHelper->joinVariants($query);

        $min = ':minWidth' . md5(json_encode($condition, JSON_THROW_ON_ERROR));
        $max = ':maxWidth' . md5(json_encode($condition, JSON_THROW_ON_ERROR));

        if ($condition->getMinWidth() > 0) {
            $query->andWhere('allVariants.width >= ' . $min);
            $query->setParameter($min$condition->getMinWidth());
        }

        if ($condition->getMaxWidth() > 0) {
            $query->andWhere('allVariants.width <= ' . $max);
            
public function generateCondition(
        ConditionInterface $condition,
        QueryBuilder $query,
        ShopContextInterface $context
    ) {
        $this->addCondition($condition$query);
    }

    private function addCondition(WeightCondition $condition, QueryBuilder $query): void
    {
        $this->variantHelper->joinVariants($query);

        $min = ':minLength' . md5(json_encode($condition, JSON_THROW_ON_ERROR));
        $max = ':maxLength' . md5(json_encode($condition, JSON_THROW_ON_ERROR));

        if ($condition->getMinWeight() > 0) {
            $query->andWhere('allVariants.weight >= ' . $min);
            $query->setParameter($min$condition->getMinWeight());
        }

        if ($condition->getMaxWeight() > 0) {
            $query->andWhere('allVariants.weight <= ' . $max);
            
ConditionInterface $condition,
        QueryBuilder $query,
        ShopContextInterface $context
    ) {
        $conditions = $this->criteria->getConditionsByClass(VariantCondition::class);
        $conditions = array_filter($conditionsfunction DVariantCondition $condition) {
            return $condition->expandVariants();
        });

        if (!$query->hasState(self::STATE_INCLUDES_PSEUDO_PRICE_VARIANTS)) {
            if (empty($conditions)) {
                $this->variantHelper->joinVariants($query);
                $this->joinPrices($query$context);
            } else {
                $this->listingPriceSwitcher->joinPrice($query$this->criteria, $context);
                $query->andWhere('listing_price.pseudoprice > 0');
            }

            $query->addState(self::STATE_INCLUDES_PSEUDO_PRICE_VARIANTS);
        }
    }

    public function setCriteria(Criteria $criteria)
    {
public function generateCondition(
        ConditionInterface $condition,
        QueryBuilder $query,
        ShopContextInterface $context
    ) {
        $this->addCondition($condition$query);
    }

    private function addCondition(LengthCondition $condition, QueryBuilder $query): void
    {
        $this->variantHelper->joinVariants($query);

        $min = ':minLength' . md5(json_encode($condition, JSON_THROW_ON_ERROR));
        $max = ':maxLength' . md5(json_encode($condition, JSON_THROW_ON_ERROR));

        if ($condition->getMinLength() > 0) {
            $query->andWhere('allVariants.length >= ' . $min);
            $query->setParameter($min$condition->getMinLength());
        }

        if ($condition->getMaxLength() > 0) {
            $query->andWhere('allVariants.length <= ' . $max);
            
Criteria $criteria,
        ShopContextInterface $context
    ) {
        if ($criteria->hasAttribute('product_dimensions_handled')) {
            return null;
        }

        $query = $this->queryBuilderFactory->createQuery($reverted$context);
        $query->resetQueryPart('orderBy');
        $query->resetQueryPart('groupBy');

        $this->variantHelper->joinVariants($query);

        $query->select([
            'MIN(allVariants.height) as minHeight',
            'MAX(allVariants.height) as maxHeight',
            'MIN(allVariants.weight) as minWeight',
            'MAX(allVariants.weight) as maxWeight',
            'MIN(allVariants.width) as minWidth',
            'MAX(allVariants.width) as maxWidth',
            'MIN(allVariants.length) as minLength',
            'MAX(allVariants.length) as maxLength',
        ]);

        
QueryBuilder $query,
        ShopContextInterface $context
    ) {
        $this->addCondition($condition$query);
    }

    private function addCondition(HeightCondition $condition, QueryBuilder $query): void
    {
        $min = ':minHeight' . md5(json_encode($condition, JSON_THROW_ON_ERROR));
        $max = ':maxHeight' . md5(json_encode($condition, JSON_THROW_ON_ERROR));

        $this->variantHelper->joinVariants($query);

        if ($condition->getMinHeight() > 0) {
            $query->andWhere('allVariants.height >= ' . $min);
            $query->setParameter($min$condition->getMinHeight());
        }

        if ($condition->getMaxHeight() > 0) {
            $query->andWhere('allVariants.height <= ' . $max);
            $query->setParameter($max$condition->getMaxHeight());
        }
    }
}
ConditionInterface $condition,
        QueryBuilder $query,
        ShopContextInterface $context
    ) {
        $conditions = $this->criteria->getConditionsByClass(VariantCondition::class);
        $conditions = array_filter($conditionsfunction DVariantCondition $condition) {
            return $condition->expandVariants();
        });

        if (!$query->hasState(self::STATE_INCLUDES_IMMEDIATE_DELIVERY_VARIANTS)) {
            if (empty($conditions)) {
                $this->variantHelper->joinVariants($query);
                $query->andWhere('allVariants.instock >= allVariants.minpurchase');
            } else {
                $query->andWhere('variant.instock >= variant.minpurchase');
            }
            $query->addState(self::STATE_INCLUDES_IMMEDIATE_DELIVERY_VARIANTS);
        }
    }

    public function setCriteria(Criteria $criteria)
    {
        $this->criteria = $criteria;
    }
Home | Imprint | This part of the site doesn't use cookies.