private function getCustomerByEmail(string
$customerId, string
$email, Context
$context, ?string
$boundSalesChannelId): ?CustomerEntity
{ $criteria =
new Criteria();
$criteria->
setLimit(1
);
if ($boundSalesChannelId) { $criteria->
addAssociation('boundSalesChannel'
);
} $criteria->
addFilter(new EqualsFilter('email',
$email));
$criteria->
addFilter(new EqualsFilter('guest', false
));
$criteria->
addFilter(new NotFilter( NotFilter::CONNECTION_AND,
[new EqualsFilter('id',
$customerId)] ));
$criteria->
addFilter(new MultiFilter(MultiFilter::CONNECTION_OR,
[ new EqualsFilter('boundSalesChannelId', null
),
new EqualsFilter('boundSalesChannelId',
$boundSalesChannelId),
]));
/** @var ?CustomerEntity $customer */
$customer =
$this->customerRepo->
search($criteria,
$context)->
first();