LocalizedAttributeField transformer

Creates a new array entry for each row that contains the source field. This is used, if you have entries like this:

[
    'attribute_key_1.de_DE' => 'deAttributeKey1Test',
    'value_1.de_DE' => 'deValue1Test',
    'attribute_key_1.en_US' => 'enAttributeKey1Test',
    'value_1.en_US' => 'enValue1Test',
    'attribute_key_2.de_DE' => 'deAttributeKey2Test',
    'value_2.de_DE' => 'deValue2Test',
    'attribute_key_2.en_US' => 'enAttributeKey2Test',
    'value_2.en_US' => 'enValue2Test',
]

There are many entries with a counter and a locale. The goal of this transformer, is to prepare the Data to be loaded later. You need to provide the prefix, to get the key and the prefix to get the value. Its gonna split the Data with array_key => value and save it to the desired localeID. The localeIds are read from the Shop. So only known locals will be loaded.

The Transformer is build like this:

<localized-attribute-fields
    fromPrefix="attribute_key_"
    valuePrefix="value_"
    to="attributes"
/>

Attributes:

  • fromPrefix - name of the field to be transformed, prefix means it starts with it

  • valuePrefix - name of the field to read the value, prefix means it starts with it (if targetField not set)

  • to - name of the field to be created

FromPrefix is used to get the keys. In this example fromPrefix = attribute_key_. That means, its gonna look for all attribute_key_ add a counter to it, and the locale of the shop. If this entry is in the pipeline, the value is gonna be loaded as the key.

ValuePrefix follows the same structure. Thats the field where the value is read. At the end, the response will use the localeID as a key to store the right locales. It will looks like this:

46 => [
    'attributes' => [
    'deAttributeKey1Test' => 'deValue1Test',
    'deAttributeKey2Test' => 'deValue2Test',
    ],
],
66 => [
    'attributes' => [
    'enAttributeKey1Test' => 'enValue1Test',
    'enAttributeKey2Test' => 'enValue2Test',
    ],
],