getMaxWeight example


        $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);
            $query->setParameter($max$condition->getMaxWeight());
        }
    }
}
ShopContextInterface $context
    ) {
        $search->addPostFilter($this->getQuery($criteriaPart));
    }

    private function getQuery(WeightCondition $criteriaPart): RangeQuery
    {
        $range = [];
        if ($criteriaPart->getMinWeight()) {
            $range['gte'] = $criteriaPart->getMinWeight();
        }
        if ($criteriaPart->getMaxWeight()) {
            $range['lte'] = $criteriaPart->getMaxWeight();
        }

        return new RangeQuery('weight', $range);
    }
}
Home | Imprint | This part of the site doesn't use cookies.