The Synonyms are defined in the %PLUGIN_DIR%/Resources/config/Synonyms.php
. The path to this file is saved in the swag_ses_synonym_dir
parameter of the container and can be overridden with the default Dependency Injection. See How to override for more information.
{% hint style="info" %} The syntax in the association may look a bit strange, it's the Solr syntax. {% endhint %}
The path parameter is afterwards passed to the Swag\EnterpriseSearch\Relevance\SynonymProvider
class.
{% code title="Synonyms.php" %}
<?php declare(strict_types=1);
use Swag\EnterpriseSearch\Relevance\SynonymProvider;
return [
SynonymProvider::DEFAULT_KEY => [
'i-pod, i pod => ipod',
'universe, cosmos',
],
];
{% endcode %}
The SynonymProvider
supports multi languages and a default fallback! For a specific language the language code can be added as an array key, like the following.
{% code title="Synonyms.php with multi language support" %}
<?php declare(strict_types=1);
use Swag\EnterpriseSearch\Relevance\SynonymProvider;
return [
SynonymProvider::DEFAULT_KEY => [
'i-pod, i pod => ipod',
'universe, cosmos',
],
'en-GB' => [
'foozball, foosball',
'sea biscuit, sea biscit => seabiscuit',
],
];
{% endcode %}
- Shopware Configuration
- Shopware is based on symfony, so it's possible to override the Service parameters in symfony style.
- Parametername
swag_ses_synonym_dir
- Own Plugin 1. Create a plugin
- Add a dependency injection file
- Create a file with your synonyms, see Example
- Add a parameter to the Dependency Injection File.
{% code title="services.xml" %}
<parameters>
<parameter key="swag_ses_synonym_dir">%kernel.project_dir%/MySynonyms.php</parameter>
</parameter>
{% endcode %}
{% hint style="warning" %} Make sure that the paths matches! {% endhint %}