Reputation: 618
How to write in TYPO3 the sites config.yaml for SOLR extension:
2 languages, Acceptance and Production.
I get from the webhost:
solr_host_read: solrprod02.xx.io
solr_core_read:
Since EXT:solr 11 it seems typoscript conditions are not allowed anymore for the connections (Legacy mode).
So how to configure for each baseVariant and each language the core?
The example in the documentation only provides an hint for the languages, not for the baseVariants https://docs.typo3.org/p/apache-solr-for-typo3/solr/11.1/en-us/Backend/ConnectionManager.html
Upvotes: 0
Views: 423
Reputation: 7939
A very simple way is to use the typo3conf/AdditionalConfiguration.php
file and check the context there:
<?php
$context = (string)\TYPO3\CMS\Core\Core\Environment::getContext();
if ($context === 'Production/Staging') {
putenv('SOLR_ENABLED_READ=true');
putenv('SOLR_HOST=solr');
putenv('SOLR_PATH=/solr/');
putenv('SOLR_PORT=8983');
putenv('SOLR_SCHEME=http');
putenv('SOLR_CORE_NAME_DE=core_de');
putenv('SOLR_USER=');
putenv('SOLR_PWD=');
}
and in your site config
solr_enabled_read: true
solr_host_read: '%env(SOLR_HOST)%'
solr_password_read: '%env(SOLR_PWD)%'
solr_path_read: '%env(SOLR_PATH)%'
solr_port_read: '%env(SOLR_PORT)%'
solr_scheme_read: '%env(SOLR_SCHEME)%'
solr_use_write_connection: false
solr_username_read: '%env(SOLR_USER)%'
languages:
-
title: Deutsch
enabled: true
languageId: '0'
base: /
typo3Language: de
locale: de
iso-639-1: de
navigationTitle: Deutsch
hreflang: de-de
direction: ''
flag: at
solr_core_read: '%env(SOLR_CORE_NAME_DE)%'
Upvotes: 2