Skip to content

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.

INFO

The syntax in the association is the Solr syntax.

The path parameter is later passed to the Swag\EnterpriseSearch\Relevance\SynonymProvider class.

Example

php
// Synonyms.php
<?php declare(strict_types=1);

use Swag\EnterpriseSearch\Relevance\SynonymProvider;

return [
    SynonymProvider::DEFAULT_KEY => [
        'i-pod, i pod => ipod',
        'universe, cosmos',
    ],
];

The SynonymProvider supports multi-languages and a default fallback. The language code can be added as an array key for a specific language, like the following:

php
// 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',
    ],
];

How to override

  1. Shopware configuration
    1. Shopware is based on Symfony, so it is possible to override the Service parameters in Symfony style.
    2. Parametername swag_ses_synonym_dir
  2. Own plugin
    1. Create a plugin
    2. Add a Dependency Injection file
    3. Create a file with your Synonyms
    4. Add a parameter to the Dependency Injection file.
html
// services.xml
<parameters>
    <parameter key="swag_ses_synonym_dir">%kernel.project_dir%/MySynonyms.php</parameter>
</parameter>

WARNING

Make sure that the paths match.