$cheapestPriceQuery->
andWhere( '(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'
)) {