Introduction

This section explains how to deal with translated fields in synQup and Shopware.handle translations in Shopware and your data. It also explains how to deal with different formats of locales between your data and Shopware.

Background - Translations in synQup and Shopware

Translations in synQup are implemented by fields of type TranslationCollection:

/**  
 * @var TranslationCollection  
 * @MongoDB\EmbedMany(collectionClass=TranslationCollection::class, targetDocument=Translation::class, strategy="set")
 */
private TranslationCollection $name;  

This is an example of how you can create a translation collection:

$name = TranslationCollection::create([Locale::en_GB, 'Car'], [Locale::de_DE, 'Auto']);
$name = new TranslationCollection();
$name->add(new Translation(Locale::en_GB, 'Car'));

You can find a set of locales in Elio\CommonBundle\Definition\Locale.

Translations in Shopware are stored in separate _translation tables. The module is able to map a TranslationCollection to the corresponding _translation table in Shopware.

Locales

Shopware uses locales in the format "xx-XX" (e.g. "en-GB"). To support different formats used in your source data, the configuration contains the locales key. Here you can determine which source locales are mapped to which Shopware locales.

The configuration follows this pattern:

{
  "locales": {
    "{{shopware-locale-1}}": [
      "{{synqup-locale-1}}",
      "{{synqup-locale-2}}",
      "{{synqup-locale-3}}"
    ],
    "{{shopware-locale-2}}": [
      "{{synqup-locale-4}}",
      "{{synqup-locale-5}}"
    ]
  }
}

Example:

{
  "locales": {
    "de-DE": [
      "de",
      "de_DE",
      "de_CH"
    ],
    "en-GB": [
      "en",
      "en_US",
      "en_GB"
    ]
  }
}

The configuration means the following:

  • All translations assigned to any of the locales de, de_DE or de_CH (and de-DE of course) will be mapped to the Shopware locale de-DE.
  • All translations assigned to one of the locale en or en_US (and en-GB) will be mapped to the shopware locale en-GB.
  • All other locales in your transfer data are ignored.

Please keep the following rules in mind:

  • The locales are prioritized by their order of definition: If a TranslationCollection contains multiple locales that are mapped to the same Shopware locale, the value of the synQup-locale defined first in the configuration will be used.
  • If you do not add a locales configuration the locale of your transfer data must be equal to the locale in Shopware. Otherwise, a value will be ignored.

Incompatibilities

Due to different data models in synQup and Shopware it can happen that a non-translated source value is mapped to a translated Shopware field and vice versa. In this case the following rules apply:

  • If a TranslationCollection is mapped to a non-translated field in Shopware, only the value for the default language in Shopware is mapped to the shop.
  • If a non-translated field from your document is mapped to a _translation table in Shopware the source value will be written into the default system locale.