/**
* Searches for all packages that can be built from the provided list of groups.
* Every line item will be taken from the cart and only the ones that are left will
* be checked for upcoming groups.
*
* @param LineItemGroupDefinition[] $groupDefinitions
*/
public function findGroupPackages(array
$groupDefinitions, Cart
$cart, SalesChannelContext
$context): LineItemGroupBuilderResult
{ $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());