Website settings with sites

When using different sites in Pimcore, the website settings doesn’t load correctly.

$websiteConfig = \Pimcore\Config::getWebsiteConfig();
$emailDocument = $websiteConfig->get(‘emailDoc’);

It get the website settings from the main website, but not the website settings from the site configured in the website settings.
I have 3 emailDoc configured in the website settings.
One for the main website and two others for different site configured (siteId 1 & 2).

Do I need to configure something else to get the website setting for the current siteId?

I’ve found a solution to write my own ConfigService that load the correct config files for subsite.

It should work by default in Pimcore, but I remember there being a bug if you add the main site once (the one without a concrete site selected), it chooses that over the ones with a site selected. If you remove the main one again, and add it to the bottom of the list, it works.

Hi, thanks for you input. I will try this too.

Hi, I’m using Pimcore 6.4, but for some reason when I setup two website settings with the same name ex. testName (language de) and testName (language en). It doesn’t show me the correct website setting.

$websiteConfig = \Pimcore\Config::getWebsiteConfig(‘en’);
$testName = $websiteConfig->get(‘testName’);

Output: testName (language de)

Do you know if there is a way to output the correct website settings in specific language?

Hi @kriscr

I have used the following way to get the website config and that worked fine for me.

$websiteSetting = \Pimcore\Model\WebsiteSetting::getByName($name, $siteId, $language, $fallbackLanguage);
$data = $websiteSetting->getData();

Ok, thanks.

I’ve made a FrontendController with
$this->view->config = \Pimcore\Tool\Frontend::getWebsiteConfig($this->language);
So I can use it anyware like

But it doesn’t look at the language param in website settings.

I will try to change it like the way you describe.