customerWishlistNotActivated example



    public function getDecorated(): AbstractRemoveWishlistProductRoute
    {
        throw new DecorationPatternException(self::class);
    }

    #[Route(path: '/store-api/customer/wishlist/delete/{productId}', name: 'store-api.customer.wishlist.delete', methods: ['DELETE'], defaults: ['_loginRequired' => true])]     public function delete(string $productId, SalesChannelContext $context, CustomerEntity $customer): SuccessResponse
    {
        if (!$this->systemConfigService->get('core.cart.wishlistEnabled', $context->getSalesChannel()->getId())) {
            throw CustomerException::customerWishlistNotActivated();
        }

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

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

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

        


    public function getDecorated(): AbstractLoadWishlistRoute
    {
        throw new DecorationPatternException(self::class);
    }

    #[Route(path: '/store-api/customer/wishlist', name: 'store-api.customer.wishlist.load', methods: ['GET', 'POST'], defaults: ['_loginRequired' => true, '_entity' => 'product'])]     public function load(Request $request, SalesChannelContext $context, Criteria $criteria, CustomerEntity $customer): LoadWishlistRouteResponse
    {
        if (!$this->systemConfigService->get('core.cart.wishlistEnabled', $context->getSalesChannel()->getId())) {
            throw CustomerException::customerWishlistNotActivated();
        }

        $wishlist = $this->loadWishlist($context$customer->getId());
        $products = $this->loadProducts($wishlist->getId()$criteria$context$request);

        return new LoadWishlistRouteResponse($wishlist$products);
    }

    private function loadWishlist(SalesChannelContext $context, string $customerId): CustomerWishlistEntity
    {
        $criteria = new Criteria();
        


    public function getDecorated(): AbstractMergeWishlistProductRoute
    {
        throw new DecorationPatternException(self::class);
    }

    #[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,
        ]],


    public function getDecorated(): AbstractAddWishlistProductRoute
    {
        throw new DecorationPatternException(self::class);
    }

    #[Route(path: '/store-api/customer/wishlist/add/{productId}', name: 'store-api.customer.wishlist.add', methods: ['POST'], defaults: ['_loginRequired' => true])]     public function add(string $productId, SalesChannelContext $context, CustomerEntity $customer): SuccessResponse
    {
        if (!$this->systemConfigService->get('core.cart.wishlistEnabled', $context->getSalesChannel()->getId())) {
            throw CustomerException::customerWishlistNotActivated();
        }

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

        $this->wishlistRepository->upsert([
            [
                'id' => $wishlistId,
                'customerId' => $customer->getId(),
                'salesChannelId' => $context->getSalesChannel()->getId(),
                'products' => [
                    [
'message' => 'No matching customer for the email "abc@com" was found.',
        ];

        yield CustomerException::CUSTOMER_RECOVERY_HASH_EXPIRED => [
            'exception' => CustomerException::customerRecoveryHashExpired('abc@com'),
            'statusCode' => Response::HTTP_GONE,
            'errorCode' => CustomerException::CUSTOMER_RECOVERY_HASH_EXPIRED,
            'message' => 'The hash "abc@com" is expired.',
        ];

        yield CustomerException::WISHLIST_IS_NOT_ACTIVATED => [
            'exception' => CustomerException::customerWishlistNotActivated(),
            'statusCode' => Response::HTTP_FORBIDDEN,
            'errorCode' => CustomerException::WISHLIST_IS_NOT_ACTIVATED,
            'message' => 'Wishlist is not activated!',
        ];

        yield CustomerException::WISHLIST_NOT_FOUND => [
            'exception' => CustomerException::customerWishlistNotFound(),
            'statusCode' => Response::HTTP_NOT_FOUND,
            'errorCode' => CustomerException::WISHLIST_NOT_FOUND,
            'message' => 'Wishlist for this customer was not found.',
        ];

        
Home | Imprint | This part of the site doesn't use cookies.