From 08bea0fdda23bd8e68ac235ced38856350d12dcf Mon Sep 17 00:00:00 2001 From: PantherX99 <121259031+PantherX99@users.noreply.github.com> Date: Tue, 2 Jun 2026 21:09:09 +0200 Subject: [PATCH 1/6] Refactor customer language joins in CustomerReader Updated joins to correctly map customer language to shop and locale. --- .../Gateway/Local/Reader/CustomerReader.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Profile/Shopware/Gateway/Local/Reader/CustomerReader.php b/src/Profile/Shopware/Gateway/Local/Reader/CustomerReader.php index 2dfbd0ed6..57839b5f8 100644 --- a/src/Profile/Shopware/Gateway/Local/Reader/CustomerReader.php +++ b/src/Profile/Shopware/Gateway/Local/Reader/CustomerReader.php @@ -87,7 +87,21 @@ private function fetchCustomers(MigrationContextInterface $migrationContext): ar $query->leftJoin('defaultpayment', 's_core_paymentmeans_attributes', 'defaultpayment_attributes', 'defaultpayment.id = defaultpayment_attributes.paymentmeanID'); $this->addTableSelection($query, 's_core_paymentmeans_attributes', 'defaultpayment_attributes', $migrationContext); - $query->leftJoin('customer', 's_core_locales', 'customerlanguage', 'customer.language = customerlanguage.id'); + // customer.language maps to the shopID and not directly to the localeID + $query->leftJoin( + 'customer', + 's_core_shops', + 'customerlanguageshop', + 'customer.language = customerlanguageshop.id' + ); + + $query->leftJoin( + 'customerlanguageshop', + 's_core_locales', + 'customerlanguage', + 'customerlanguageshop.locale_id = customerlanguage.id' + ); + $this->addTableSelection($query, 's_core_locales', 'customerlanguage', $migrationContext); $query->leftJoin('customer', 's_core_shops', 'shop', 'customer.subshopID = shop.id'); From eb306903d050d6918fdde1a82a0d3b7f86ed577e Mon Sep 17 00:00:00 2001 From: PantherX99 <121259031+PantherX99@users.noreply.github.com> Date: Tue, 2 Jun 2026 21:34:52 +0200 Subject: [PATCH 2/6] Fix: fetch correct locale from shop instead of customer.language customer.language maps to the shopId and not the localeId. mapping now correctly fetches existing locales from the shop association to prevent unnecessary / unused languages to be created --- .../Gateway/Local/Reader/LanguageReader.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php b/src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php index f1cff213a..b50d267ea 100644 --- a/src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php +++ b/src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php @@ -86,12 +86,22 @@ private function fetchShopLocaleIds(MigrationContextInterface $migrationContext) private function fetchCustomerLocaleIds(MigrationContextInterface $migrationContext): array { $connection = $this->getConnection($migrationContext); + $query = $connection->createQueryBuilder(); $query->from('s_user', 'customer'); - $query->addSelect('customer.language'); + + $query->leftJoin( + 'customer', + 's_core_shops', + 'customerlanguageshop', + 'customer.language = customerlanguageshop.id' + ); + + $query->addSelect('customerlanguageshop.locale_id'); $query->distinct(); $query->where('customer.language IS NOT NULL'); - + $query->andWhere('customerlanguageshop.locale_id IS NOT NULL'); + return $query->executeQuery()->fetchFirstColumn(); } From 151911b219d769ca291a08f0d94552d628009ef0 Mon Sep 17 00:00:00 2001 From: Phil Beckord Date: Wed, 3 Jun 2026 11:01:52 +0200 Subject: [PATCH 3/6] extended tests: added third shop with locale 192 (ro-RO), changed shop and language of user 3, modified tests for sales channel and customer reader --- tests/Profile/Shopware/Gateway/Local/CustomerReaderTest.php | 2 +- .../Shopware/Gateway/Local/SalesChannelReaderTest.php | 6 +++++- tests/_fixtures/database/shopware55.sql | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/Profile/Shopware/Gateway/Local/CustomerReaderTest.php b/tests/Profile/Shopware/Gateway/Local/CustomerReaderTest.php index d3272eb1c..3a2e86f3c 100644 --- a/tests/Profile/Shopware/Gateway/Local/CustomerReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/CustomerReaderTest.php @@ -74,7 +74,7 @@ public function testRead(): void static::assertSame('5', $data[2]['default_billing_address_id']); static::assertSame('5', $data[2]['default_shipping_address_id']); static::assertSame('prepayment', $data[2]['defaultpayment']['name']); - static::assertSame('de-DE', $data[2]['customerlanguage']['locale']); + static::assertSame('ro-RO', $data[2]['customerlanguage']['locale']); static::assertSame('0', $data[2]['shop']['customer_scope']); static::assertCount(1, $data[2]['addresses']); } diff --git a/tests/Profile/Shopware/Gateway/Local/SalesChannelReaderTest.php b/tests/Profile/Shopware/Gateway/Local/SalesChannelReaderTest.php index ce3fe03a0..9995fdb23 100644 --- a/tests/Profile/Shopware/Gateway/Local/SalesChannelReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/SalesChannelReaderTest.php @@ -60,11 +60,15 @@ public function testRead(): void static::assertSame('de-DE', $data[0]['_locale']); static::assertSame('EUR', $data[0]['currency']); - static::assertCount(1, $data[0]['children']); + static::assertCount(2, $data[0]['children']); static::assertSame('39', $data[0]['children'][0]['category_id']); static::assertSame('en-GB', $data[0]['children'][0]['locale']); static::assertSame('de-DE', $data[0]['children'][0]['_locale']); static::assertSame('EUR', $data[0]['children'][0]['currency']); + static::assertSame('39', $data[0]['children'][1]['category_id']); + static::assertSame('ro-RO', $data[0]['children'][1]['locale']); + static::assertSame('de-DE', $data[0]['children'][1]['_locale']); + static::assertSame('EUR', $data[0]['children'][1]['currency']); } public function testReadTotal(): void diff --git a/tests/_fixtures/database/shopware55.sql b/tests/_fixtures/database/shopware55.sql index beee565e5..262998c41 100644 --- a/tests/_fixtures/database/shopware55.sql +++ b/tests/_fixtures/database/shopware55.sql @@ -4001,7 +4001,7 @@ CREATE TABLE `s_core_shops` ( LOCK TABLES `s_core_shops` WRITE; /*!40000 ALTER TABLE `s_core_shops` DISABLE KEYS */; -INSERT INTO `s_core_shops` VALUES (1,NULL,'Deutsch',NULL,0,'sw55.local','',NULL,'',0,23,23,3,1,1,1,NULL,0,1,1),(2,1,'English','English',0,NULL,NULL,NULL,'',0,NULL,NULL,39,2,1,1,2,0,0,1); +INSERT INTO `s_core_shops` VALUES (1,NULL,'Deutsch',NULL,0,'sw55.local','',NULL,'',0,23,23,3,1,1,1,NULL,0,1,1),(2,1,'English','English',0,NULL,NULL,NULL,'',0,NULL,NULL,39,2,1,1,2,0,0,1),(3, 1, 'Romanian', 'Romanian', 0, NULL, NULL, NULL, '', 0, NULL, NULL, 39, 192, 1, 1, 3, 0, 0, 1); /*!40000 ALTER TABLE `s_core_shops` ENABLE KEYS */; UNLOCK TABLES; @@ -7658,7 +7658,7 @@ CREATE TABLE `s_user` ( LOCK TABLES `s_user` WRITE; /*!40000 ALTER TABLE `s_user` DISABLE KEYS */; -INSERT INTO `s_user` VALUES (1,'a256a310bc1e5db755fd392c524028a8','md5','test@example.com',1,0,'',5,0,NULL,NULL,'2011-11-23','2012-01-04 14:12:05','uiorqd755gaar8dn89ukp178c7',0,'',0,'EK',0,'1',1,'',NULL,'',0,NULL,1,3,NULL,'mr','Max','Mustermann',NULL,'20001',NULL,NULL,'2019-11-13 13:47:27',NULL),(2,'352db51c3ff06159d380d3d9935ec814','md5','mustermann@b2b.de',1,0,'',4,0,NULL,NULL,'2012-08-30','2012-08-30 11:43:17','66e9b10064a19b1fcf6eb9310c0753866c764836',0,'0',0,'H',4,'1',1,'',NULL,'',0,NULL,2,4,NULL,'mr','Händler','Kundengruppe-Netto',NULL,'20003',NULL,NULL,'2019-11-13 13:47:27',NULL),(3,'$2y$10$NVX9a/qzhoo0jS6U3i7YH.jBluI0hsOFqCnw/obStDxxkexPlDuHC','bcrypt','k.luetjann@shopware.com',1,0,'',5,0,NULL,NULL,'2020-02-26','2020-02-26 08:01:53','bioapqo043f3csuoctclulor7t',0,'0',0,'H',0,'1',1,'',NULL,'',0,NULL,5,5,'','mr','Krispin','Luetjann',NULL,'20005','27e8f8d6-a59d-476e-a6f0-9fcbbd03faf1.1','2020-02-26 08:00:31','2020-02-26 07:40:50',NULL); +INSERT INTO `s_user` VALUES (1,'a256a310bc1e5db755fd392c524028a8','md5','test@example.com',1,0,'',5,0,NULL,NULL,'2011-11-23','2012-01-04 14:12:05','uiorqd755gaar8dn89ukp178c7',0,'',0,'EK',0,'1',1,'',NULL,'',0,NULL,1,3,NULL,'mr','Max','Mustermann',NULL,'20001',NULL,NULL,'2019-11-13 13:47:27',NULL),(2,'352db51c3ff06159d380d3d9935ec814','md5','mustermann@b2b.de',1,0,'',4,0,NULL,NULL,'2012-08-30','2012-08-30 11:43:17','66e9b10064a19b1fcf6eb9310c0753866c764836',0,'0',0,'H',4,'1',1,'',NULL,'',0,NULL,2,4,NULL,'mr','Händler','Kundengruppe-Netto',NULL,'20003',NULL,NULL,'2019-11-13 13:47:27',NULL),(3,'$2y$10$NVX9a/qzhoo0jS6U3i7YH.jBluI0hsOFqCnw/obStDxxkexPlDuHC','bcrypt','k.luetjann@shopware.com',1,0,'',5,0,NULL,NULL,'2020-02-26','2020-02-26 08:01:53','bioapqo043f3csuoctclulor7t',0,'0',0,'H',0,'3',3,'',NULL,'',0,NULL,5,5,'','mr','Krispin','Luetjann',NULL,'20005','27e8f8d6-a59d-476e-a6f0-9fcbbd03faf1.1','2020-02-26 08:00:31','2020-02-26 07:40:50',NULL); /*!40000 ALTER TABLE `s_user` ENABLE KEYS */; UNLOCK TABLES; From 1dd4c2f090eb1b3550dd1e7e501c8199ac1933b1 Mon Sep 17 00:00:00 2001 From: Phil Beckord Date: Wed, 3 Jun 2026 11:08:11 +0200 Subject: [PATCH 4/6] join with s_core_locales for safety as well --- .../Shopware/Gateway/Local/Reader/LanguageReader.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php b/src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php index b50d267ea..acab00109 100644 --- a/src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php +++ b/src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php @@ -96,11 +96,19 @@ private function fetchCustomerLocaleIds(MigrationContextInterface $migrationCont 'customerlanguageshop', 'customer.language = customerlanguageshop.id' ); + + $query->leftJoin( + 'customerlanguageshop', + 's_core_locales', + 'customerlocales', + 'customerlanguageshop.locale_id = customerlocales.id' + ); - $query->addSelect('customerlanguageshop.locale_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->executeQuery()->fetchFirstColumn(); } From e1c8c9ba05389d78d6d9f49330caedfc5a584520 Mon Sep 17 00:00:00 2001 From: PantherX99 <121259031+PantherX99@users.noreply.github.com> Date: Wed, 3 Jun 2026 13:00:35 +0200 Subject: [PATCH 5/6] Update expected total in SalesChannelReaderTest --- tests/Profile/Shopware/Gateway/Local/SalesChannelReaderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Profile/Shopware/Gateway/Local/SalesChannelReaderTest.php b/tests/Profile/Shopware/Gateway/Local/SalesChannelReaderTest.php index 9995fdb23..67fc8523a 100644 --- a/tests/Profile/Shopware/Gateway/Local/SalesChannelReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/SalesChannelReaderTest.php @@ -83,6 +83,6 @@ public function testReadTotal(): void static::assertNotNull($dataSet); static::assertSame($dataSet::getEntity(), $totalStruct->getEntityName()); - static::assertSame(2, $totalStruct->getTotal()); + static::assertSame(3, $totalStruct->getTotal()); } } From 11f73f902fa75396e23688ba3348d4af2b3ff21c Mon Sep 17 00:00:00 2001 From: PantherX99 <121259031+PantherX99@users.noreply.github.com> Date: Thu, 4 Jun 2026 18:08:30 +0200 Subject: [PATCH 6/6] no whitespace in blank line --- .../Shopware/Gateway/Local/Reader/LanguageReader.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php b/src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php index acab00109..0d3d4148a 100644 --- a/src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php +++ b/src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php @@ -86,10 +86,10 @@ private function fetchShopLocaleIds(MigrationContextInterface $migrationContext) private function fetchCustomerLocaleIds(MigrationContextInterface $migrationContext): array { $connection = $this->getConnection($migrationContext); - + $query = $connection->createQueryBuilder(); $query->from('s_user', 'customer'); - + $query->leftJoin( 'customer', 's_core_shops', @@ -103,13 +103,13 @@ private function fetchCustomerLocaleIds(MigrationContextInterface $migrationCont '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->executeQuery()->fetchFirstColumn(); }