From 64dff920d3702b6c0dc9cca9ad0543bb2737835e Mon Sep 17 00:00:00 2001 From: Lars Kemper Date: Tue, 28 Apr 2026 15:22:10 +0200 Subject: [PATCH 1/3] fix: include customer locales in language migration --- Service/LanguageService.php | 20 ++++++- .../Service/LanguageServiceTest.php | 56 +++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 Tests/Functional/Service/LanguageServiceTest.php diff --git a/Service/LanguageService.php b/Service/LanguageService.php index de9b8cc..774d0a3 100644 --- a/Service/LanguageService.php +++ b/Service/LanguageService.php @@ -34,7 +34,11 @@ public function __construct(ModelManager $modelManager) */ public function getLanguages() { - $fetchedShopLocaleIds = \array_unique($this->fetchShopLocaleIds()); + $fetchedShopLocaleIds = \array_unique(\array_merge( + $this->fetchShopLocaleIds(), + $this->fetchCustomerLocaleIds() + )); + $locales = $this->fetchLocales($fetchedShopLocaleIds); return $this->appendAssociatedData($locales); @@ -76,6 +80,20 @@ private function fetchShopLocaleIds() return $query->execute()->fetchAll(\PDO::FETCH_COLUMN); } + /** + * @return array + */ + private function fetchCustomerLocaleIds() + { + $query = $this->connection->createQueryBuilder(); + $query->from('s_user', 'customer'); + $query->addSelect('customer.language'); + $query->distinct(); + $query->where('customer.language IS NOT NULL'); + + return $query->execute()->fetchAll(\PDO::FETCH_COLUMN); + } + /** * @return array */ diff --git a/Tests/Functional/Service/LanguageServiceTest.php b/Tests/Functional/Service/LanguageServiceTest.php new file mode 100644 index 0000000..82d8f86 --- /dev/null +++ b/Tests/Functional/Service/LanguageServiceTest.php @@ -0,0 +1,56 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace SwagMigrationConnector\Tests\Functional\Service; + +use Doctrine\DBAL\Connection; +use PHPUnit\Framework\TestCase; +use SwagMigrationConnector\Tests\Functional\DatabaseTransactionTrait; + +class LanguageServiceTest extends TestCase +{ + use DatabaseTransactionTrait; + + /** + * @var Connection + */ + private $connection; + + /** + * @return void + */ + public function testReadIncludesCustomerLocalesOutsideShopLocales() + { + $localeId = (int) $this->connection->fetchColumn('SELECT COALESCE(MAX(id), 0) + 1 FROM s_core_locales'); + $customerId = $this->connection->fetchColumn('SELECT id FROM s_user ORDER BY id ASC LIMIT 1'); + + static::assertNotFalse($customerId); + + $this->connection->insert('s_core_locales', [ + 'id' => $localeId, + 'locale' => 'zz_ZZ', + 'language' => 'Test language', + 'territory' => 'Test territory', + ]); + $this->connection->update('s_user', ['language' => $localeId], ['id' => $customerId]); + + $languageService = $this->getContainer()->get('swag_migration_connector.service.language_service'); + $languages = $languageService->getLanguages(); + + static::assertContains('zz-ZZ', \array_column($languages, 'locale')); + } + + /** + * @before + * + * @return void + */ + protected function setUpMethod() + { + $this->connection = $this->getContainer()->get('dbal_connection'); + } +} From 80d9360de05c3bf865e350ead2b0fa3311cca3aa Mon Sep 17 00:00:00 2001 From: Lars Kemper Date: Tue, 28 Apr 2026 15:53:47 +0200 Subject: [PATCH 2/3] fix: ci --- Service/LanguageService.php | 3 +-- Tests/Functional/Service/LanguageServiceTest.php | 9 +++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Service/LanguageService.php b/Service/LanguageService.php index 774d0a3..49c0258 100644 --- a/Service/LanguageService.php +++ b/Service/LanguageService.php @@ -87,8 +87,7 @@ private function fetchCustomerLocaleIds() { $query = $this->connection->createQueryBuilder(); $query->from('s_user', 'customer'); - $query->addSelect('customer.language'); - $query->distinct(); + $query->addSelect('DISTINCT customer.language'); $query->where('customer.language IS NOT NULL'); return $query->execute()->fetchAll(\PDO::FETCH_COLUMN); diff --git a/Tests/Functional/Service/LanguageServiceTest.php b/Tests/Functional/Service/LanguageServiceTest.php index 82d8f86..dd21b5c 100644 --- a/Tests/Functional/Service/LanguageServiceTest.php +++ b/Tests/Functional/Service/LanguageServiceTest.php @@ -28,7 +28,7 @@ public function testReadIncludesCustomerLocalesOutsideShopLocales() $localeId = (int) $this->connection->fetchColumn('SELECT COALESCE(MAX(id), 0) + 1 FROM s_core_locales'); $customerId = $this->connection->fetchColumn('SELECT id FROM s_user ORDER BY id ASC LIMIT 1'); - static::assertNotFalse($customerId); + static::assertTrue($customerId !== false); $this->connection->insert('s_core_locales', [ 'id' => $localeId, @@ -36,7 +36,12 @@ public function testReadIncludesCustomerLocalesOutsideShopLocales() 'language' => 'Test language', 'territory' => 'Test territory', ]); - $this->connection->update('s_user', ['language' => $localeId], ['id' => $customerId]); + + $this->connection->update( + 's_user', + ['language' => (string) $localeId], + ['id' => (int) $customerId] + ); $languageService = $this->getContainer()->get('swag_migration_connector.service.language_service'); $languages = $languageService->getLanguages(); From e23ba49073b0dcf519bdb7ce88e78516f4422f4f Mon Sep 17 00:00:00 2001 From: Lars Kemper Date: Tue, 28 Apr 2026 16:03:29 +0200 Subject: [PATCH 3/3] docs: update changelog --- plugin.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugin.xml b/plugin.xml index 54198b5..3769269 100644 --- a/plugin.xml +++ b/plugin.xml @@ -19,6 +19,15 @@ The Migration Connector provides API endpoints that allow Shopware 6 to create a secure data connection with the active Shopware 5 shop which support the data migration to Shopware 6. + + + Migration von Kundensprachen korrigiert, wenn diese keinem Shop zugewiesen sind; + + + Fixed customer language migration when customer locales are not assigned to a shop; + + + #13670 - Die Umgebungsinformationen wurden angepasst, um einige Konfigurationswerte zurückzugeben, die die SW5-Installation eindeutig identifizieren. SW6 verwendet diese, um davor zu warnen, mehr als einmal Verbindungen zum selben Quellsystem herzustellen;