#[Route(path: '/store-api/customer/wishlist/merge', name: 'store-api.customer.wishlist.merge', methods: ['POST'], defaults: ['_loginRequired' => true])]
public function merge(RequestDataBag
$data, SalesChannelContext
$context, CustomerEntity
$customer): SuccessResponse
{ if (!
$this->systemConfigService->
get('core.cart.wishlistEnabled',
$context->
getSalesChannel()->
getId())) { throw CustomerException::
customerWishlistNotActivated();
} $wishlistId =
$this->
getWishlistId($context,
$customer->
getId());
$upsertData =
$this->
buildUpsertProducts($data,
$wishlistId,
$context);
$this->wishlistRepository->
upsert([[ 'id' =>
$wishlistId,
'customerId' =>
$customer->
getId(),
'salesChannelId' =>
$context->
getSalesChannel()->
getId(),
'products' =>
$upsertData,
]],
$context->
getContext());
$this->eventDispatcher->
dispatch(new WishlistMergedEvent($upsertData,
$context));
return new SuccessResponse();
}