How to change default language in shopware6 from backend?

Hey guys! I had the same problem and i finally found a solution without touching the code!

The id of the default language is the same since the start of shopware 6 (2fbb5fe2e29a4d70aa5854ce7ce3e20b) and the db contains foreign-key-references with “on update cascade” for every reference on language_id (language-table). I just updated the id of the english language in the language-table to a new random uuid and afterwards updated the id of the german language to 2fbb5fe2e29a4d70aa5854ce7ce3e20b (see code below).

mysql --user={{ sw_db_user }} --password={{ sw_db_user_password }}
    {{ sw_database_name }} --host={{ sw_database_host }} --batch --skip-column-names
    --execute="
    UPDATE language SET id = UNHEX(REPLACE(UUID(), '-','')) WHERE name='English';
    UPDATE language SET id = UNHEX('2FBB5FE2E29A4D70AA5854CE7CE3E20B') WHERE name='Deutsch';"

I did this shortly after setting up the db with the command bin/console system:install --create-database --basic-setup and before building the application for the first time. I also did the following the make it working as expected:

  • changed the default language for the admin-user to german

    mysql --user={{ sw_db_user }} --password={{ sw_db_user_password }}
    {{ sw_database_name }} --host={{ sw_database_host }} --batch --skip-column-names
    –execute="
    UPDATE user SET locale_id = (SELECT id FROM locale WHERE code = ‘de-DE’) WHERE username = ‘admin’;"

  •  changed the default language, currency AND snippet-set for all SalesChannel-Domains

    mysql --user={{ sw_db_user }} --password={{ sw_db_user_password }}
    {{ sw_database_name }} --host={{ sw_database_host }} --batch --skip-column-names
    –execute="
    UPDATE sales_channel_domain SET language_id = (SELECT id FROM language WHERE name = ‘Deutsch’),
    currency_id = (SELECT id FROM currency WHERE iso_code = ‘EUR’),
    snippet_set_id = (SELECT id FROM snippet_set WHERE iso = ‘de-DE’);"

  • changed the default language, currency and country for all SalesChannels

    mysql --user={{ sw_db_user }} --password={{ sw_db_user_password }}
    {{ sw_database_name }} --host={{ sw_database_host }} --batch --skip-column-names
    –execute="
    UPDATE sales_channel SET language_id = (SELECT id FROM language WHERE name = ‘Deutsch’),
    currency_id = (SELECT id FROM currency WHERE iso_code = ‘EUR’),
    country_id = (SELECT id FROM country WHERE iso3 = ‘DEU’);"

Afterwards you only have to give your storefront-channel a new name (german) because the db-setup-process only inserts a translation for english.

The parent_id-field in the language-table is NULL for all entries (german and english)

1 „Gefällt mir“