Fix customer autocomplete filter not displaying guest customers (#18980)

Guest customers (without first/last name) appeared as blank entries in the
order grid's customer autocomplete filter, making them impossible to select.

Added `getNameOrEmail()` to `CustomerInterface` which returns
`"Full Name (email)"` for named customers and just the email for guests,
and switched the order grid filter to use it as its choice label.
This commit is contained in:
Abderrahim GHAZALI 2026-04-20 12:28:19 +02:00
parent 50e3576804
commit a75fd35347
3 changed files with 14 additions and 1 deletions

View file

@ -114,7 +114,7 @@ sylius_grid:
form_options:
extra_options:
class: '%sylius.model.customer.class%'
choice_label: fullname
choice_label: nameOrEmail
date:
type: date
label: sylius.ui.date

View file

@ -89,6 +89,17 @@ class Customer implements CustomerInterface, \Stringable
return trim(sprintf('%s %s', $this->firstName, $this->lastName));
}
public function getNameOrEmail(): string
{
$fullName = $this->getFullName();
if ('' !== $fullName) {
return sprintf('%s (%s)', $fullName, $this->email);
}
return (string) $this->email;
}
public function getFirstName(): ?string
{
return $this->firstName;

View file

@ -37,6 +37,8 @@ interface CustomerInterface extends TimestampableInterface, ResourceInterface
public function getFullName(): string;
public function getNameOrEmail(): string;
public function getFirstName(): ?string;
public function setFirstName(?string $firstName): void;