$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);
// now build a package with our packager
$group =
$packager->
buildGroupPackage($groupDefinition->
getValue(),
$itemsToConsider,
$context);
// if we have no found items in our group, quit
if (!
$group->
hasItems()) { break;
} // append the currently found group of items
// to our group definition inside our result object
$result->
addGroup($groupDefinition,
$group);
// decrease rest of cart items for next search
$restOfCart =
$this->
adjustRestOfCart($group->
getItems(),
$restOfCart);
} }