Leon Schwanitz
Leon Schwanitz

Reputation: 283

Shopware 6 App - Individual text fields in config for each storefront (translatable)

When i change the text in one storefront the text is also changed in the other storefront (cause its the same snippet).

This is my snippet:

<component name="sw-snippet-field">
    <name>leftBoxTitle</name>
    <label>Title</label>
    <label lang="de-DE">Titel</label>
    <snippet>minds-atcch.leftBoxTitle</snippet>
</component>

How it is possible to create a snippet (or custom input field) for each storefront individually that is translatable?

Upvotes: 0

Views: 260

Answers (1)

dneustadt
dneustadt

Reputation: 13161

If one and the same snippet should resolve to different content you'll have to create a separate snippet set. One snippet set may inherit the contents of another so you may have two sales channels assigned to two different snippet sets. One of the snippet sets may inherit all of its snippets from the original except for those snippets that you want to be different in the corresponding storefront.

Also see this answer for a few more details.

As for the component sw-snippet-field it detects which snippet set to use from the current language of the API context. Changing the sales channel in the dropdown on top of the form will not change the language though. So this component will probably still not behave the way you intend it to. You could create a custom component which extends sw-snippet-field but overrides the method where the snippet set is retrieved by the current locale and instead uses the selected sales channel to determine which set should be used.

Upvotes: 0

Related Questions