GENERAL
BACKEND
FRONTEND
ADDITIONAL
Note: This Plugin supports ElasticSearch 7.0 and above. If you're looking for ElasticSearch Plugin for older versions check SyliusElasticSearchPlugin in version 1.x.
We work on stable, supported and up-to-date versions of packages. We recommend you to do the same.
| Package | Version |
|---|---|
| PHP | >=8.1 |
| sylius/sylius | 1.12.x - 1.13.x |
| MySQL | >= 5.7 |
| NodeJS | >= 18.x |
| ElasticSearch | >= 7.x |
composer require bitbag/elasticsearch-plugin --no-scriptsAdd plugin dependencies to your config/bundles.php file:
# config/bundles.php
return [
...
FOS\ElasticaBundle\FOSElasticaBundle::class => ['all' => true],
BitBag\SyliusElasticsearchPlugin\BitBagSyliusElasticsearchPlugin::class => ['all' => true],
];Import required config in your config/packages/_sylius.yaml file:
# config/packages/_sylius.yaml
imports:
...
- { resource: "@BitBagSyliusElasticsearchPlugin/config/config.yml" }Import routing on top of your config/routes/sylius_shop.yaml file:
Note. The code presented below needs to be loaded before including the sylius_shop routes. Please be sure, that it's being loaded first.
# config/routes.yaml
bitbag_sylius_elasticsearch_plugin:
resource: "@BitBagSyliusElasticsearchPlugin/config/routing.yml"Remove the default ElasticSearch index (app) defined by FOSElasticaBundle in config/packages/fos_elastica.yaml:
# config/packages/fos_elastica.yaml
fos_elastica:
clients:
default: { url: '%env(ELASTICSEARCH_URL)%' }
indexes:
app: ~should become:
fos_elastica:
clients:
default: { url: '%env(ELASTICSEARCH_URL)%' }Use BitBag\SyliusElasticsearchPlugin\Model\ProductVariantTrait and BitBag\SyliusElasticsearchPlugin\Model\ProductVariantInterface in an overridden ProductVariant entity class.
The configuration, depending on the mapping used, may vary.
bin/console assets:installbin/console cache:clearbin/console fos:elastica:populateNote: If you are running it on production, add the -e prod flag to this command. Elastic are created with environment suffix.
Please setup your webpack.config.js file to require the plugin's webpack configuration. To do so, please put the line below somewhere on top of your webpack.config.js file:
const [ bitbagElasticSearchShop ] = require('./vendor/bitbag/elasticsearch-plugin/webpack.config.js')As next step, please add the imported consts into final module exports:
module.exports = [..., bitbagElasticSearchShop];Add the asset configuration into config/packages/assets.yaml:
framework:
assets:
packages:
...
elasticsearch_shop:
json_manifest_path: '%kernel.project_dir%/public/build/bitbag/elasticsearch/shop/manifest.json'Add the webpack configuration into config/packages/webpack_encore.yaml:
webpack_encore:
output_path: '%kernel.project_dir%/public/build/default'
builds:
...
elasticsearch_shop: '%kernel.project_dir%/public/build/bitbag/elasticsearch/shop'Add encore functions to your templates:
{# @templates/shop/javascripts.html.twig #}
{{ encore_entry_script_tags('bitbag-elasticsearch-shop', null, 'elasticsearch_shop') }}
{# @templates/shop/stylesheets.html.twig #}
{{ encore_entry_link_tags('bitbag-elasticsearch-shop', null, 'elasticsearch_shop') }}yarn install
yarn encore dev # or prod, depends on your environmentElasticsearch's port settings can be found in the .env file.
###> friendsofsymfony/elastica-bundle ###
ELASTICSEARCH_URL=http://localhost:9200/
###< friendsofsymfony/elastica-bundle ###For incorrectly displayed translations, execute the command:
bin/console cache:clear