Skip to content
Elasticsearch integration for Sylius apps.
Branch: master
Clone or download
Latest commit 2dea56d Jun 25, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update to Sylius 1.3 🎉 Oct 22, 2018
doc Add logo Feb 7, 2019
etc/build Update to Sylius 1.3 🎉 Oct 22, 2018
features/shop Fixed tests Apr 1, 2019
spec Adjust CS May 20, 2019
src Update ContainsNameQueryBuilder.php May 21, 2019
tests Review fixes implementd Apr 1, 2019
.gitignore Fixed tests Apr 1, 2019
.travis.yml removed phpstan Feb 11, 2019
LICENSE Create LICENSE Feb 7, 2019 Update Jun 25, 2019
behat.yml.dist Fix naming Mar 20, 2019
composer.json Fixed tests Apr 1, 2019
easy-coding-standard.yml Use SyliusLabs/CodingStandard ^2.0 Jul 3, 2018
node_modules init Mar 1, 2018
phpspec.yml.dist init Mar 1, 2018

BitBag SyliusElasticsearchPlugin

Working Sylius Elasticsearch integration based on FOSElasticaBundle. The main goal of this plugin is to support filtering products by options, attributes, taxons, channels and name in the front product list page. It totally replaces the default Sylius sylius_shop_product_index route.

If you are curious about the details of this plugin, read this Medium blog post for more details.

What is more, the plugin has a nice Sylius-oriented architecture that allows mapping resources to the Elastic document easier. It is flexible as well, so that you can customize the existing features for your specific business needs.


You can order our support on this page.

We work on amazing eCommerce projects on top of Sylius and other great Symfony based solutions, like eZ Platform, Akeneo or Pimcore. Need some help or additional resources for a project? Write us an email on or visit our website! 🚀


We created a demo app with some useful use-cases of the plugin! Visit to take a look at it. The admin can be accessed under link and sylius: sylius credentials.


If you use Sylius 1.4, you might get a compatibility issue for Pagerfanta. Please read this issue in order to proceed with a workaround.

$ composer require bitbag/elasticsearch-plugin

Add plugin dependencies to your config/bundles.php file:

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

    - { resource: "@BitBagSyliusElasticsearchPlugin/Resources/config/config.yml" }

Import routing on top of your config/routes.yaml file:

# config/routes.yaml

    resource: "@BitBagSyliusElasticsearchPlugin/Resources/config/routing.yml"

...and set up the redirection from the default Sylius shop products index page on top of your config/routes/sylius_shop.yaml file.

# config/routes/sylius_shop.yaml

    path: /{_locale}/taxons/{slug}
    controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
        route: bitbag_sylius_elasticsearch_plugin_shop_list_products
        permanent: true
        _locale: ^[a-z]{2}(?:_[A-Z]{2})?$
        slug: .+

With a elasticsearch server running, execute following command:

$ bin/console fos:elastica:populate

Note: If you are running it on production, add the -e prod flag to this command. Elastic are created with environment suffix.


Rendering the shop products list

When you go now to the /{_locale}/products/taxon/{slug} page, you should see a totally new set of filters. You should see something like this:

You might also want to refer the horizontal menu to a new product list page. Follow below instructions to do so:

  1. If you haven't done it yet, create two files:
    • _horizontalMenu.html.twig in templates/bundles/SyliusShopBundle/Taxon directory
    • _breadcrumb.html.twig in templates/bundles/SyliusShopBundle/Product/Show directory
  2. Paste into those files content of respectively vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/views/Taxon/_horizontalMenu.html.twig and vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/views/Product/Show/_breadcrumb.html.twig files, replacing sylius_shop_product_index with bitbag_sylius_elasticsearch_plugin_shop_list_products in both of them.
  3. Clean your cache with bin/console cache:clear command.
  4. 🎉

If you're using vertical menu - follow steps above with _verticalMenu.html.twig file instead. It's in the same directory as the horizontal_menu.html.twig file.

Be aware! Elasticsearch does not handle dashes well. This plugin depends on the code field in Sylius resources. Please use underscores instead of dashes in your code fields.

Excluding options and attributes in the filter menu

You might not want to show some specific options or attributes in the menu. You can set specific parameters for that:

    bitbag_es_excluded_filter_options: []
    bitbag_es_excluded_filter_attributes: ['book_isbn', 'book_pages']

By default all options and attributes are indexed. After you change these parameters, remember to run bin/console fo:el:po command again (a shortcut for fos:elastica:populate).


By default, current indexes listen on all Doctrine events. You can override this setting for each index by overriding index definition in your config.yml file:

                            insert: true
                            update: false
                            delete: true

Indexes with bitbag_shop_product, bitbag_attribute_taxons and bitbag_option_taxons keys are available so far.


Available services you can decorate and forms you can extend

$ bin/console debug:container | grep bitbag_sylius_elasticsearch_plugin

Parameters you can override in your parameters.yml(.dist) file

$ bin/console debug:container --parameters | grep bitbag


$ composer install
$ cd tests/Application
$ yarn install
$ yarn run gulp
$ bin/console assets:install public -e test
$ bin/console doctrine:schema:create -e test
$ bin/console server:run -d public -e test
$ elasticsearch
$ open http://localhost:8080
$ vendor/bin/behat
$ vendor/bin/phpspec run


Learn more about our contribution workflow on

You can’t perform that action at this time.