From 007b4e7e630b3c138831bfe42ce86f87eafea5f0 Mon Sep 17 00:00:00 2001 From: PantherX99 <121259031+PantherX99@users.noreply.github.com> Date: Tue, 2 Jun 2026 21:22:11 +0200 Subject: [PATCH 1/3] Enhance customer query with additional joins Added additional joins for customer language and shop ID mapping. --- Repository/CustomerRepository.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Repository/CustomerRepository.php b/Repository/CustomerRepository.php index 16a2708..f9dc3b3 100644 --- a/Repository/CustomerRepository.php +++ b/Repository/CustomerRepository.php @@ -59,12 +59,30 @@ public function fetch($offset = 0, $limit = 250) $query->leftJoin('defaultpayment', 's_core_paymentmeans_attributes', 'defaultpayment_attributes', 'defaultpayment.id = defaultpayment_attributes.paymentmeanID'); $this->addTableSelection($query, 's_core_paymentmeans_attributes', 'defaultpayment_attributes'); - $query->leftJoin('customer', 's_core_locales', 'customerlanguage', 'customer.language = customerlanguage.id'); - $this->addTableSelection($query, 's_core_locales', 'customerlanguage'); - - $query->leftJoin('customer', 's_core_shops', 'shop', 'customer.subshopID = shop.id'); + $query->leftJoin( + 'customer', + 's_core_shops', + 'shop', + 'customer.subshopID = shop.id' + ); $this->addTableSelection($query, 's_core_shops', 'shop'); + // customer.language maps to the shopID and not the localeID + $query->leftJoin( + 'customer', + 's_core_shops', + 'customerlanguageshop', + 'customer.language = customerlanguageshop.id' + ); + + $query->leftJoin( + 'customer', + 's_core_locales', + 'customerlanguage', + 'customerlanguage.id = COALESCE(customerlanguageshop.locale_id, shop.locale_id, customer.language)' + ); + $this->addTableSelection($query, 's_core_locales', 'customerlanguage'); + $query->where('customer.id IN (:ids)'); $query->setParameter('ids', $ids, Connection::PARAM_STR_ARRAY); From 8de9bedc7dfa566817028705ff83823815865b00 Mon Sep 17 00:00:00 2001 From: PantherX99 <121259031+PantherX99@users.noreply.github.com> Date: Wed, 3 Jun 2026 11:18:10 +0200 Subject: [PATCH 2/3] remove fallback coalesce --- Repository/CustomerRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Repository/CustomerRepository.php b/Repository/CustomerRepository.php index f9dc3b3..79c27a2 100644 --- a/Repository/CustomerRepository.php +++ b/Repository/CustomerRepository.php @@ -79,7 +79,7 @@ public function fetch($offset = 0, $limit = 250) 'customer', 's_core_locales', 'customerlanguage', - 'customerlanguage.id = COALESCE(customerlanguageshop.locale_id, shop.locale_id, customer.language)' + 'customerlanguage.id = customerlanguageshop.locale_id' ); $this->addTableSelection($query, 's_core_locales', 'customerlanguage'); From 7a32592e4308f542c11cf1e1c5f7b5a7bee8ab24 Mon Sep 17 00:00:00 2001 From: PantherX99 <121259031+PantherX99@users.noreply.github.com> Date: Wed, 3 Jun 2026 11:28:32 +0200 Subject: [PATCH 3/3] Enhance fetchCustomerLocaleIds with locale joins Added left joins to fetch customer locale IDs along with language. customer.language maps to shopID and not directly to localeID --- Service/LanguageService.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Service/LanguageService.php b/Service/LanguageService.php index 49c0258..65a9b11 100644 --- a/Service/LanguageService.php +++ b/Service/LanguageService.php @@ -87,8 +87,25 @@ private function fetchCustomerLocaleIds() { $query = $this->connection->createQueryBuilder(); $query->from('s_user', 'customer'); - $query->addSelect('DISTINCT customer.language'); + $query->leftJoin( + 'customer', + 's_core_shops', + 'customerlanguageshop', + 'customer.language = customerlanguageshop.id' + ); + + $query->leftJoin( + 'customerlanguageshop', + 's_core_locales', + 'customerlocales', + 'customerlanguageshop.locale_id = customerlocales.id' + ); + + $query->addSelect('customerlocales.id'); + $query->distinct(); $query->where('customer.language IS NOT NULL'); + $query->andWhere('customerlanguageshop.locale_id IS NOT NULL'); + $query->andWhere('customerlocales.id IS NOT NULL'); return $query->execute()->fetchAll(\PDO::FETCH_COLUMN); }