customerNotFound example

'message' => 'No matching customer for the hash "id-1" was found.',
        ];

        yield CustomerException::CUSTOMER_NOT_FOUND_BY_ID => [
            'exception' => CustomerException::customerNotFoundByIdException('id-1'),
            'statusCode' => Response::HTTP_NOT_FOUND,
            'errorCode' => CustomerException::CUSTOMER_NOT_FOUND_BY_ID,
            'message' => 'No matching customer for the id "id-1" was found.',
        ];

        yield CustomerException::CUSTOMER_NOT_FOUND => [
            'exception' => CustomerException::customerNotFound('abc@com'),
            'statusCode' => Response::HTTP_NOT_FOUND,
            'errorCode' => CustomerException::CUSTOMER_NOT_FOUND,
            '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.',
        ];

        
$criteria->addFilter(new EqualsFilter('customer.email', $email));
        $criteria->addFilter(new EqualsFilter('customer.guest', 0));

        $criteria->addFilter(new MultiFilter(MultiFilter::CONNECTION_OR, [
            new EqualsFilter('customer.boundSalesChannelId', null),
            new EqualsFilter('customer.boundSalesChannelId', $context->getSalesChannel()->getId()),
        ]));

        $result = $this->customerRepository->search($criteria$context->getContext());

        if ($result->count() !== 1) {
            throw CustomerException::customerNotFound($email);
        }

        $customer = $result->first();
        \assert($customer instanceof CustomerEntity);

        return $customer;
    }

    private function deleteRecoveryForCustomer(CustomerRecoveryEntity $existingRecovery, Context $context): void
    {
        $recoveryData = [
            
/** * @throws CustomerNotFoundException */
    private function getCustomerByEmail(string $email, SalesChannelContext $context, bool $includeGuest = false): CustomerEntity
    {
        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('email', $email));

        $customer = $this->fetchCustomer($criteria$context$includeGuest);
        if ($customer === null) {
            throw CustomerException::customerNotFound($email);
        }

        return $customer;
    }

    /** * @throws CustomerNotFoundByIdException */
    private function getCustomerById(string $id, SalesChannelContext $context): CustomerEntity
    {
        $criteria = new Criteria([$id]);

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