foreach ($customers as $customer) { $updateData[] =
[ 'id' =>
$customer->
getId(),
'requestedGroupId' => null,
'groupId' =>
$customer->
getRequestedGroupId(),
];
} $this->customerRepository->
update($updateData,
$context);
foreach ($customers as $customer) { $salesChannelContext =
$this->restorer->
restoreByCustomer($customer->
getId(),
$context);
/** @var CustomerEntity $customer */
$customer =
$salesChannelContext->
getCustomer();
$criteria =
new Criteria([$customer->
getGroupId()]);
$criteria->
setLimit(1
);
$customerRequestedGroup =
$this->customerGroupRepository->
search($criteria,
$salesChannelContext->
getContext())->
first();
if ($customerRequestedGroup === null
) { throw CustomerException::
customerGroupNotFound($customer->
getGroupId());
}