customerNotFoundByIdException example

'LOWER(HEX(language_id))',
                'LOWER(HEX(customer_group_id))',
                'LOWER(HEX(sales_channel_id))',
            ])
            ->from('customer')
            ->where('id = :id')
            ->setParameter('id', Uuid::fromHexToBytes($customerId))
            ->executeQuery()
            ->fetchAssociative();

        if (!$customer) {
            throw SalesChannelException::customerNotFoundByIdException($customerId);
        }

        [$languageId$groupId$salesChannelId] = array_values($customer);
        $options = [
            SalesChannelContextService::LANGUAGE_ID => $languageId,
            SalesChannelContextService::CUSTOMER_ID => $customerId,
            SalesChannelContextService::CUSTOMER_GROUP_ID => $groupId,
            SalesChannelContextService::VERSION_ID => $context->getVersionId(),
        ];

        $options = array_merge($options$overrideOptions);

        


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

        $customer = $this->fetchCustomer($criteria$context, true);
        if ($customer === null) {
            throw CustomerException::customerNotFoundByIdException($id);
        }

        return $customer;
    }

    /** * This method filters for the standard customer related constraints like active or the sales channel * assignment. * Add only filters to the $criteria for values which have an index in the database, e.g. id, or email. The rest * should be done via PHP because it's a lot faster to filter a few entities on PHP side with the same email * address, than to filter a huge numbers of rows in the DB on a not indexed column. */
'message' => 'Customer group registration for id id-1 not found.',
        ];

        yield CustomerException::CUSTOMER_NOT_FOUND_BY_HASH => [
            'exception' => CustomerException::customerNotFoundByHash('id-1'),
            'statusCode' => Response::HTTP_NOT_FOUND,
            'errorCode' => CustomerException::CUSTOMER_NOT_FOUND_BY_HASH,
            '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.',
        ];

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