$graduation = 'prices.from = 1';
if ($this->config->
get('useLastGraduationForCheapestPrice'
)) { $graduation = "IF(priceGroup.id IS NOT NULL, prices.from = 1, prices.to = 'beliebig')";
} $subQuery->
where('prices.pricegroup = :customerGroup'
) ->
andWhere($graduation) ->
andWhere('variant.active = 1'
) ->
andWhere('prices.articleID = outerPrices.articleID'
);
$subQuery->
setMaxResults(1
);
if ($this->config->
get('calculateCheapestPriceWithMinPurchase'
)) { /*
* Sorting by the cheapest available price
*/
$subQuery->
orderBy('(prices.price * variant.minpurchase)'
);
} else { /*
* Sorting by the cheapest unit price
*/
$subQuery->
orderBy('prices.price'
);
}