I have the following situation. I have a custom CMS-Element with a form in it, I send the data via a AJAX in a written JS-Plugin to a custom controller. Now I would like to read informations from the CMS-Element Config. I peeked inside the Source of the Contact-Form and ended in their controller where they read out the configuration. I implemented it in my controller and basicly it worked but the only thing that isn’t working is that I always get the config of one Language (German). My Primary language is English and my secondary is German.
I took the “Dailymotion” example from the guides. And added melted it with the code from the other guide for AJAX calls. (For testing purpose)
https://developer.shopware.com/docs/guides/plugins/plugins/content/cms/add-cms-element https://developer.shopware.com/docs/guides/plugins/plugins/storefront/add-dynamic-content-via-ajax-calls
In the source of the ContactForm (ContactFormRoute.php) are the lines with
$mailConfigs['receivers'] = $slot->getEntities()->first()->getTranslated()['config']['mailReceiver']['value'];
I’ve added the same but I only get the secondary language config data.
I modified the code that he get the dailyUrl value from the config.
What I noticed is that in my $context the languageIdChain contains both language IDs (the first one is the German one) in the contact thereis only the languageId of the current language:
These are the languageIdChain of the Context sended in the English language. (2fbb5fe2e29a4d70aa5854ce7ce3e20b is the English Language)
Context languageIdChain of the Contact form controller:
#languageIdChain: array:1 [
0 => "2fbb5fe2e29a4d70aa5854ce7ce3e20b"
]
Context languageIdChain of my controller:
#languageIdChain: array:2 [
0 => "2d7d7d698f634a04b5796e49aa846ae6"
1 => "2fbb5fe2e29a4d70aa5854ce7ce3e20b"
]