Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion Service/LanguageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -76,6 +80,19 @@ private function fetchShopLocaleIds()
return $query->execute()->fetchAll(\PDO::FETCH_COLUMN);
}

/**
* @return array<int, string>
*/
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
*/
Expand Down
61 changes: 61 additions & 0 deletions Tests/Functional/Service/LanguageServiceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* (c) shopware AG <info@shopware.com>
* 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');
}
}
9 changes: 9 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
</description>

<changelog version="NEXT">
<changes lang="de">
Migration von Kundensprachen korrigiert, wenn diese keinem Shop zugewiesen sind;
</changes>
<changes lang="en">
Fixed customer language migration when customer locales are not assigned to a shop;
</changes>
</changelog>

<changelog version="2.2.0">
<changes lang="de">
#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;
Expand Down
Loading