Synonyms
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.
The syntax in the association may look a bit strange, it's the Solr syntax.
The path parameter is afterwards passed to the Swag\EnterpriseSearch\Relevance\SynonymProvider class.

Example

Synonyms.php
1
<?php declare(strict_types=1);
2
3
use Swag\EnterpriseSearch\Relevance\SynonymProvider;
4
5
return [
6
SynonymProvider::DEFAULT_KEY => [
7
'i-pod, i pod => ipod',
8
'universe, cosmos',
9
],
10
];
Copied!
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.
Synonyms.php with multi language support
1
<?php declare(strict_types=1);
2
3
use Swag\EnterpriseSearch\Relevance\SynonymProvider;
4
5
return [
6
SynonymProvider::DEFAULT_KEY => [
7
'i-pod, i pod => ipod',
8
'universe, cosmos',
9
],
10
'en-GB' => [
11
'foozball, foosball',
12
'sea biscuit, sea biscit => seabiscuit',
13
],
14
];
Copied!

How to override

  1. 1.
    Shopware Configuration
    1. 1.
      Shopware is based on symfony, so it's possible to override the Service parameters in symfony style.
    2. 2.
      Parametername swag_ses_synonym_dir
  2. 2.
    Own Plugin 1. Create a plugin
    1. 2.
      Create a file with your synonyms, see Example
    2. 3.
      Add a parameter to the Dependency Injection File.
services.xml
1
<parameters>
2
<parameter key="swag_ses_synonym_dir">%kernel.project_dir%/MySynonyms.php</parameter>
3
</parameter>
Copied!
Make sure that the paths matches!
Copy link
Edit on GitHub