From a75fd35347e948b3889e7fa0dcccbe3456dccaab Mon Sep 17 00:00:00 2001 From: Abderrahim GHAZALI Date: Mon, 20 Apr 2026 12:28:19 +0200 Subject: [PATCH 1/2] 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. --- .../AdminBundle/Resources/config/grids/order.yml | 2 +- src/Sylius/Component/Customer/Model/Customer.php | 11 +++++++++++ .../Component/Customer/Model/CustomerInterface.php | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/grids/order.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/grids/order.yml index 21746fcad1..adb9b2b9b7 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/grids/order.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/grids/order.yml @@ -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 diff --git a/src/Sylius/Component/Customer/Model/Customer.php b/src/Sylius/Component/Customer/Model/Customer.php index e7650fdf00..fb35aaf55e 100644 --- a/src/Sylius/Component/Customer/Model/Customer.php +++ b/src/Sylius/Component/Customer/Model/Customer.php @@ -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; diff --git a/src/Sylius/Component/Customer/Model/CustomerInterface.php b/src/Sylius/Component/Customer/Model/CustomerInterface.php index cc252d4ab8..31e3720210 100644 --- a/src/Sylius/Component/Customer/Model/CustomerInterface.php +++ b/src/Sylius/Component/Customer/Model/CustomerInterface.php @@ -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; From 9a8cdcdd73b4c7e2fe533f206fb1f3ec745c9024 Mon Sep 17 00:00:00 2001 From: Abderrahim GHAZALI Date: Mon, 20 Apr 2026 12:38:28 +0200 Subject: [PATCH 2/2] Handle null email in getNameOrEmail() to avoid "Name ()" label --- src/Sylius/Component/Customer/Model/Customer.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Sylius/Component/Customer/Model/Customer.php b/src/Sylius/Component/Customer/Model/Customer.php index fb35aaf55e..4a5921b43e 100644 --- a/src/Sylius/Component/Customer/Model/Customer.php +++ b/src/Sylius/Component/Customer/Model/Customer.php @@ -93,10 +93,14 @@ class Customer implements CustomerInterface, \Stringable { $fullName = $this->getFullName(); - if ('' !== $fullName) { + if ('' !== $fullName && null !== $this->email) { return sprintf('%s (%s)', $fullName, $this->email); } + if ('' !== $fullName) { + return $fullName; + } + return (string) $this->email; }