diff --git a/Service/LanguageService.php b/Service/LanguageService.php index de9b8cc..49c0258 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,19 @@ 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('DISTINCT customer.language'); + $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..dd21b5c --- /dev/null +++ b/Tests/Functional/Service/LanguageServiceTest.php @@ -0,0 +1,61 @@ + + * 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::assertTrue($customerId !== false); + + $this->connection->insert('s_core_locales', [ + 'id' => $localeId, + 'locale' => 'zz_ZZ', + 'language' => 'Test language', + 'territory' => 'Test territory', + ]); + + $this->connection->update( + 's_user', + ['language' => (string) $localeId], + ['id' => (int) $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'); + } +} 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;