WishlistProductRemovedEvent example

$wishlistId = $this->getWishlistId($context$customer->getId());

        $wishlistProductId = $this->getWishlistProductId($wishlistId$productId$context);

        $this->productRepository->delete([
            [
                'id' => $wishlistProductId,
            ],
        ]$context->getContext());

        $this->eventDispatcher->dispatch(new WishlistProductRemovedEvent($wishlistId$productId$context));

        return new SuccessResponse();
    }

    private function getWishlistId(SalesChannelContext $context, string $customerId): string
    {
        $criteria = new Criteria();
        $criteria->setLimit(1);
        $criteria->addFilter(new MultiFilter(MultiFilter::CONNECTION_AND, [
            new EqualsFilter('customerId', $customerId),
            new EqualsFilter('salesChannelId', $context->getSalesChannel()->getId()),
        ]));
Home | Imprint | This part of the site doesn't use cookies.