Translations example

'salutation_key' => self::SALUTATION_KEY,
            'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ];

        try {
            $connection->insert('salutation', $salutation);
        } catch (UniqueConstraintViolationException) {
            // Already exists, skip translation insertion too             return;
        }

        $translation = new Translations(
            [
                'salutation_id' => Uuid::fromHexToBytes(self::DEFAULT_SALUTATION_ID),
                'display_name' => self::SALUTATION_DISPLAY_NAME_DE,
                'letter_name' => '',
            ],
            [
                'salutation_id' => Uuid::fromHexToBytes(self::DEFAULT_SALUTATION_ID),
                'display_name' => self::SALUTATION_DISPLAY_NAME_EN,
                'letter_name' => '',
            ]
        );

        
'key' => 'active', 'mappedKey' => 'active'],
                ['key' => 'position', 'mappedKey' => 'position'],
                ['key' => 'limit', 'mappedKey' => 'limit'],
                ['key' => 'type', 'mappedKey' => 'type'],
                ['key' => 'sortBy', 'mappedKey' => 'sort_by'],
                ['key' => 'sortDirection', 'mappedKey' => 'sort_direction'],
                ['key' => 'assignedProducts', 'mappedKey' => 'assigned_products'],
            ]),
            'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);

        $translations = new Translations(
            [
                'import_export_profile_id' => $id,
                'label' => 'Standardprofil Cross-Selling',
            ],
            [
                'import_export_profile_id' => $id,
                'label' => 'Default cross-selling',
            ]
        );

        $this->importTranslation(ImportExportProfileTranslationDefinition::ENTITY_NAME, $translations$connection);
    }


    public function update(Connection $connection): void
    {
        $id = Uuid::randomBytes();

        $connection->insert(MailHeaderFooterDefinition::ENTITY_NAME, [
            'id' => $id,
            'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);

        $translations = new Translations(
            [
                'mail_header_footer_id' => $id,
                'name' => 'Standard-E-Mail-Fußzeile',
                'description' => 'Standard-E-Mail-Fußzeile basierend auf den Stammdaten',
                'header_html' => null,
                'header_plain' => null,
                'footer_plain' => (string) \file_get_contents(__DIR__ . '/../Fixtures/mails/defaultMailFooter/de-plain.twig'),
                'footer_html' => (string) \file_get_contents(__DIR__ . '/../Fixtures/mails/defaultMailFooter/de-html.twig'),
            ],
            [
                'mail_header_footer_id' => $id,
                
    }

    public function createDefaultSortingsWithTranslations(Connection $connection): void
    {
        foreach ($this->getDefaultSortings() as $sorting) {
            $translations = $sorting['translations'];

            unset($sorting['translations']);

            $connection->insert(ProductSortingDefinition::ENTITY_NAME, $sorting);

            $translations = new Translations(
                ['product_sorting_id' => $sorting['id'], 'label' => $translations['de-DE']],
                ['product_sorting_id' => $sorting['id'], 'label' => $translations['en-GB']]
            );

            $this->importTranslation('product_sorting_translation', $translations$connection);
        }
    }

    private function createTable(Connection $connection): void
    {
        $connection->executeStatement(' CREATE TABLE IF NOT EXISTS `product_sorting` ( `id` BINARY(16) NOT NULL, `url_key` VARCHAR(255) NOT NULL, `priority` INT(11) unsigned NOT NULL, `active` TINYINT(1) NOt NULL DEFAULT 1, `fields` JSON NOT NULL, `created_at` DATETIME(3) NOT NULL, `locked` TINYINT(1) NOT NULL DEFAULT 0, `updated_at` DATETIME(3) NULL, PRIMARY KEY (`id`), CONSTRAINT `uniq.product_sorting.url_key` UNIQUE (`url_key`), CONSTRAINT `json.product_sorting.fields` CHECK (JSON_VALID(`fields`)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ');
$deLanguageId = $this->fetchLanguageIdByName('de-DE', $connection);

        $searchConfigEnId = $connection->fetchOne('SELECT id FROM product_search_config WHERE language_id = :language_id', ['language_id' => $enLanguageId])
            ?: Uuid::randomBytes();

        $searchConfigDeId = $connection->fetchOne('SELECT id FROM product_search_config WHERE language_id = :language_id', ['language_id' => $deLanguageId])
            ?: Uuid::randomBytes();

        $enStopwords = require __DIR__ . '/../Fixtures/stopwords/en.php';
        $deStopwords = require __DIR__ . '/../Fixtures/stopwords/de.php';

        $translations = new Translations(
            [
                'id' => $searchConfigDeId,
                'and_logic' => 1,
                'min_search_length' => 2,
                'excluded_terms' => json_encode($deStopwords, \JSON_THROW_ON_ERROR),
            ],
            [
                'id' => $searchConfigEnId,
                'and_logic' => 1,
                'min_search_length' => 2,
                'excluded_terms' => $enLanguageId ? json_encode($enStopwords, \JSON_THROW_ON_ERROR) : null,
            ]
$this->connection->insert(
            StateMachineDefinition::ENTITY_NAME,
            [
                'id' => $id,
                'technical_name' => $stateMachineMigration->getTechnicalName(),
                'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
            ]
        );

        $this->importTranslation(
            StateMachineTranslationDefinition::ENTITY_NAME,
            new Translations(
                ['state_machine_id' => $id, 'name' => $stateMachineMigration->getDe()],
                ['state_machine_id' => $id, 'name' => $stateMachineMigration->getEn()]
            ),
            $this->connection
        );

        return Uuid::fromBytesToHex($id);
    }

    private function createOrSkipExistingStateMachineState(
        StateMachineMigration $stateMachineMigration,
        
$countryStateData = [
                'id' => $countryStateId,
                'country_id' => $countryId,
                'short_code' => $state['shortCode'],
                'position' => 1,
                'active' => 1,
                'created_at' => $createdAt,
            ];

            $queue->addInsert('country_state', $countryStateData);

            $countryStateTranslations[] = new Translations([
                'country_state_id' => $countryStateId,
                'name' => $state['nameDE'],
            ][
                'country_state_id' => $countryStateId,
                'name' => $state['nameEN'],
            ]);
        }

        $queue->execute();

        foreach ($countryStateTranslations as $translations) {
            
return;
        }

        $connection->insert('delivery_time', [
            'id' => $downloadDeliveryTime,
            'min' => 0,
            'max' => 0,
            'unit' => 'hour',
            'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);

        $translation = new Translations(
            [
                'delivery_time_id' => $downloadDeliveryTime,
                'name' => self::DELIVERY_TIME_NAME_DE,
            ],
            [
                'delivery_time_id' => $downloadDeliveryTime,
                'name' => self::DELIVERY_TIME_NAME_EN,
            ]
        );

        $this->importTranslation('delivery_time_translation', $translation$connection);
    }
$connection->insert('number_range_sales_channel', [
            'id' => Uuid::randomBytes(),
            'number_range_id' => $numberRangeId,
            'sales_channel_id' => Uuid::fromHexToBytes(TestDefaults::SALES_CHANNEL),
            'number_range_type_id' => $numberRangeTypeId,
            'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);
    }

    private function insertTranslations(Connection $connection, string $numberRangeId, string $numberRangeTypeId): void
    {
        $numberRangeTranslations = new Translations(
            [
                'number_range_id' => $numberRangeId,
                'name' => 'Beispiel',
            ],
            [
                'number_range_id' => $numberRangeId,
                'name' => 'Example',
            ]
        );

        $numberRangeTypeTranslations = new Translations(
            [
'id' => Uuid::fromHexToBytes($ids->create('category')),
            'version_id' => Uuid::fromHexToBytes(Defaults::LIVE_VERSION),
            'type' => 'category',
            'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ];

        KernelLifecycleManager::getConnection()
            ->insert('category', $data);

        $this->importTranslation(
            'category_translation',
            new Translations(
                [
                    'category_id' => Uuid::fromHexToBytes($ids->get('category')),
                    'category_version_id' => Uuid::fromHexToBytes(Defaults::LIVE_VERSION),
                    'name' => 'de name',
                ],
                [
                    'category_id' => Uuid::fromHexToBytes($ids->get('category')),
                    'category_version_id' => Uuid::fromHexToBytes(Defaults::LIVE_VERSION),
                    'name' => 'en name',
                ]
            ),
            
 else {
            $connection->insert(
                'mail_template_type',
                [
                    'id' => $typeId,
                    'technical_name' => $technicalName,
                    'available_entities' => json_encode(['salesChannel' => 'sales_channel']),
                    'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
                ]
            );

            $translations = new Translations(
                [
                    'mail_template_type_id' => $typeId,
                    'name' => 'Produktbewertung',
                ],
                [
                    'mail_template_type_id' => $typeId,
                    'name' => 'Product review',
                ]
            );

            $this->importTranslation('mail_template_type_translation', $translations$connection);
        }
'key' => 'considerAdvancedRules', 'mappedKey' => 'consider_advanced_rules', 'position' => 5],
                ['key' => 'maxValue', 'mappedKey' => 'max_value', 'position' => 6],
                ['key' => 'sorterKey', 'mappedKey' => 'sorter_key', 'position' => 7, 'useDefaultValue' => true, 'defaultValue' => 'PRICE_ASC'],
                ['key' => 'applierKey', 'mappedKey' => 'applier_key', 'position' => 8, 'useDefaultValue' => true, 'defaultValue' => 'ALL'],
                ['key' => 'usageKey', 'mappedKey' => 'usage_key', 'position' => 9, 'useDefaultValue' => true, 'defaultValue' => 'ALL'],
                ['key' => 'pickerKey', 'mappedKey' => 'picker_key', 'position' => 10],
                ['key' => 'discountRules', 'mappedKey' => 'discount_rules', 'position' => 11],
            ]),
            'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);

        $translations = new Translations(
            [
                'import_export_profile_id' => $id,
                'label' => 'Standardprofil Aktionsrabatte',
            ],
            [
                'import_export_profile_id' => $id,
                'label' => 'Default promotion discounts',
            ]
        );

        $this->importTranslation(ImportExportProfileTranslationDefinition::ENTITY_NAME, $translations$connection);
    }
'key' => 'defaultShippingAddress.lastName', 'mappedKey' => 'shipping_last_name'],
                ['key' => 'defaultShippingAddress.company', 'mappedKey' => 'shipping_company'],
                ['key' => 'defaultShippingAddress.street', 'mappedKey' => 'shipping_street'],
                ['key' => 'defaultShippingAddress.zipcode', 'mappedKey' => 'shipping_zipcode'],
                ['key' => 'defaultShippingAddress.city', 'mappedKey' => 'shipping_city'],
                ['key' => 'defaultShippingAddress.country.iso', 'mappedKey' => 'shipping_country'],
                ['key' => 'defaultShippingAddress.phoneNumber', 'mappedKey' => 'shipping_phone_number'],
            ]),
            'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);

        $translations = new Translations(
            [
                'import_export_profile_id' => $id,
                'label' => 'Standardprofil Kunde',
            ],
            [
                'import_export_profile_id' => $id,
                'label' => 'Default customer',
            ]
        );

        $this->importTranslation(ImportExportProfileTranslationDefinition::ENTITY_NAME, $translations$connection);
    }
'key' => 'id', 'mappedKey' => 'id', 'position' => 0],
                ['key' => 'productId', 'mappedKey' => 'product_id', 'position' => 1],
                ['key' => 'ruleId', 'mappedKey' => 'rule_id', 'position' => 2],
                ['key' => 'price.DEFAULT.net', 'mappedKey' => 'price_net', 'position' => 3],
                ['key' => 'price.DEFAULT.gross', 'mappedKey' => 'price_gross', 'position' => 4],
                ['key' => 'quantityStart', 'mappedKey' => 'quantity_start', 'position' => 5],
                ['key' => 'quantityEnd', 'mappedKey' => 'quantity_end', 'position' => 6],
            ]),
            'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);

        $translations = new Translations(
            [
                'import_export_profile_id' => $id,
                'label' => 'Standardprofil Erweiterte Preise',
            ],
            [
                'import_export_profile_id' => $id,
                'label' => 'Default advanced prices',
            ]
        );

        $this->importTranslation(ImportExportProfileTranslationDefinition::ENTITY_NAME, $translations$connection);
    }
$connection->insert(
                    'mail_template_type',
                    [
                        'id' => $values['typeId'],
                        'technical_name' => $technicalName,
                        'available_entities' => json_encode(['order' => 'order', 'salesChannel' => 'sales_channel']),
                        'template_data' => '{"order":{"orderNumber":"10060","orderCustomer":{"firstName":"Max","lastName":"Mustermann"}},"salesChannel":{"name":"Storefront"}}',
                        'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
                    ]
                );

                $translations = new Translations(
                    [
                        'mail_template_type_id' => $values['typeId'],
                        'name' => $values['nameDe'],
                    ],
                    [
                        'mail_template_type_id' => $values['typeId'],
                        'name' => $values['name'],
                    ]
                );

                $this->importTranslation('mail_template_type_translation', $translations$connection);
            }
Home | Imprint | This part of the site doesn't use cookies.