SkillAgentSearch skills...

SyliusElasticsearchPlugin

Elasticsearch integration for Sylius apps.

Install / Use

/learn @BitBagCommerce/SyliusElasticsearchPlugin

README

BitBag SyliusElasticsearchPlugin


Slack Support

<p> <img align="left" src="https://sylius.com/assets/badge-approved-by-sylius.png" width="85"> </p>

We want to impact many unique eCommerce projects and build our brand recognition worldwide, so we are heavily involved in creating open-source solutions, especially for Sylius. We have already created over 35 extensions, which have been downloaded almost 2 million times.

You can find more information about our eCommerce services and technologies on our website: https://bitbag.io/. We have also created a unique service dedicated to creating plugins: https://bitbag.io/services/sylius-plugin-development.

Do you like our work? Would you like to join us? Check out the “Career” tab: https://bitbag.io/pl/kariera.

About Us


BitBag is a software house that implements tailor-made eCommerce platforms with the entire infrastructure—from creating eCommerce platforms to implementing PIM and CMS systems to developing custom eCommerce applications, specialist B2B solutions, and migrations from other platforms.

We actively participate in Sylius's development. We have already completed over 150 projects, cooperating with clients worldwide, including smaller enterprises and large international companies. We have completed projects for such important brands as Mytheresa, Foodspring, Planeta Huerto (Carrefour Group), Albeco, Mollie, and ArtNight.

We have a 70-person team of experts: business analysts and consultants, eCommerce developers, project managers, and QA testers.

Our services:

  • B2B and B2C eCommerce platform implementations
  • Multi-vendor marketplace platform implementations
  • eCommerce migrations
  • Sylius plugin development
  • Sylius consulting
  • Project maintenance and long-term support
  • PIM and CMS implementations

Some numbers from BitBag regarding Sylius:

  • 70 experts on board
  • +150 projects delivered on top of Sylius,
  • 30 countries of BitBag’s customers,
  • 7 years in the Sylius ecosystem.
  • +35 plugins created for Sylius


Table of Content


Overview


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.

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.

If you are curious about the details of this plugin, read this blog post and watch the video below.

Installation


For the full installation guide, please go here.

Requirements


This plugin requires elasticsearch server running. You can install it by following the instructions on the official website. In plugin repository there is Docker Compose file that can be used to run Elasticsearch server.

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.2 or 8.3 | | sylius/sylius | >= 2.0 | | MySQL | >= 5.7 | | NodeJS | >= 18.x | | ElasticSearch | >= 7.x |

Usage

Scope of the search

This plugin offers a site-wide search feature and taxon search feature. It is easily extendable to add more search scopes. For example in Marketplace suite you can create Vendor specific search scope.

Searching site-wide products

There is searchbar in the header of the shop.

<div align="center"> <img src="doc/es_browser.png" /> </div>

You can easily modify it by overriding the @BitBagSyliusElasticsearchPlugin/Shop/Layout/Header/searchForm.html.twig and templates @BitBagSyliusElasticsearchPlugin/Shop/SearchForm/searchForm.html.twig or disable it by setting:

sylius_twig_hooks:
  hooks:
    'sylius_shop.base.header.content':
      search_form:
        template: "@BitBagSyliusElasticsearchPlugin/Shop/Layout/Header/searchForm.html.twig"
        priority: 250
        enabled: false
    'sylius_shop.base.header.content.search_form':
      content:
        component: 'bitbag.sylius_elasticsearch_plugin:search_form'
        props:
          template: "@BitBagSyliusElasticsearchPlugin/Shop/SearchForm/searchForm.html.twig"
        priority: 0
        enabled: false

Searching taxon products

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

<div align="center"> <img src="doc/es_results.png" /> </div>

It is important that the routing.yml from the plugin are loaded before sylius_shop:

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

sylius_shop:
    resource: "@SyliusShopBundle/Resources/config/routing.yml"
    prefix: /{_locale}
    requirements:
        _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$

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:

parameters:
    bitbag_es_excluded_facet_attributes: ['jeans_material']
    bitbag_es_excluded_facet_options: ['t_shirt_size']

By default, all options and attributes filters are shown.

It is also possible to disable options and attribute filters autodiscovery by setting the following parameters:

parameters:
    bitbag_es_facets_auto_discover: false

Then you have to manually register your filters:

Available filters:

  • TaxonFacet which allows to filter your search results by taxons using the ElasticSearch Terms aggregation.
  • AttributeFacet which allows to filter your search results by product attributes values using the ElasticSearch Terms aggregation.
  • OptionFacet which is the same as AttributeFacet but for product options.
  • PriceFacet which allows to filter search results by price range the ElasticSearch Histogram aggregation.

Example of manual registration of filters:

services:
    bitbag_sylius_elasticsearch_plugin.facet.attribute.t_shirt_brand:
      class: BitBag\SyliusElasticsearchPlugin\Facet\AttributeFacet
      arguments:
        - '@bitbag_sylius_elasticsearch_plugin.property_name_resolver.attribute'
        - '@=service("sylius.repository.product_attribute").findOneBy({"code": "t_shirt_brand"})'
        - '@sylius.context.locale'

    bitbag_sylius_elasticsearch_plugin.facet.registry:
      class: BitBag\SyliusElasticsearchPlugin\Facet\Registry
      calls:
        -   method: addFacet
            arguments:
              - t_shirt_brand
              - '@bitbag_sylius_elasticsearch_plugin.facet.attribute.t_shir

Related Skills

View on GitHub
GitHub Stars133
CategoryDevelopment
Updated1mo ago
Forks95

Languages

PHP

Security Score

100/100

Audited on Feb 11, 2026

No findings