$result =
new LineItemGroupBuilderResult();
// filter out all promotion items
$cartProducts =
$this->lineItemProvider->
getProducts($cart);
// split quantities into separate line items
// so we have a real list of products like we would have
// them when holding it in our actual hands.
$restOfCart =
$this->
splitQuantities($cartProducts,
$context);
foreach ($groupDefinitions as $groupDefinition) { $sorter =
$this->registry->
getSorter($groupDefinition->
getSorterKey());
$packager =
$this->registry->
getPackager($groupDefinition->
getPackagerKey());
// we have to sort our items first
// otherwise it would be a "random" order when
// adjusting the rest of our cart...
$restOfCart =
$sorter->
sort($restOfCart);
// try as long as groups can be
// found for the current definition
while (true
) { $itemsToConsider =
$this->ruleMatcher->
getMatchingItems($groupDefinition,
$restOfCart,
$context);