customerWishlistNotFound example


        $criteria = new Criteria();
        $criteria->setLimit(1);
        $criteria->addFilter(new MultiFilter(MultiFilter::CONNECTION_AND, [
            new EqualsFilter('customerId', $customerId),
            new EqualsFilter('salesChannelId', $context->getSalesChannel()->getId()),
        ]));

        $wishlist = $this->wishlistRepository->search($criteria$context->getContext());
        $result = $wishlist->first();
        if (!$result instanceof CustomerWishlistEntity) {
            throw CustomerException::customerWishlistNotFound();
        }

        return $result;
    }

    /** * @return EntitySearchResult<ProductCollection> */
    private function loadProducts(string $wishlistId, Criteria $criteria, SalesChannelContext $context, Request $request): EntitySearchResult
    {
        $criteria->addFilter(
            
'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.',
        ];

        yield CustomerException::DUPLICATE_WISHLIST_PRODUCT => [
            'exception' => CustomerException::duplicateWishlistProduct(),
            'statusCode' => Response::HTTP_BAD_REQUEST,
            'errorCode' => CustomerException::DUPLICATE_WISHLIST_PRODUCT,
            'message' => 'Product already added in wishlist',
        ];

        

        $criteria = new Criteria();
        $criteria->setLimit(1);
        $criteria->addFilter(new MultiFilter(MultiFilter::CONNECTION_AND, [
            new EqualsFilter('customerId', $customerId),
            new EqualsFilter('salesChannelId', $context->getSalesChannel()->getId()),
        ]));

        $wishlistIds = $this->wishlistRepository->searchIds($criteria$context->getContext());

        if ($wishlistIds->firstId() === null) {
            throw CustomerException::customerWishlistNotFound();
        }

        return $wishlistIds->firstId();
    }

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