All Projects → BitBagCommerce → Syliuselasticsearchplugin

BitBagCommerce / Syliuselasticsearchplugin

Licence: mit
Elasticsearch integration for Sylius apps.

Projects that are alternatives of or similar to Syliuselasticsearchplugin

Open Loyalty
Open Loyalty is technology for loyalty solutions for starting new loyalty projects.
Stars: ✭ 476 (+440.91%)
Mutual labels:  ecommerce, elasticsearch, symfony
Elasticsearchbundle
Symfony bundle for Elasticsearch with steroids
Stars: ✭ 296 (+236.36%)
Mutual labels:  elasticsearch, symfony, symfony-bundle
Foselasticabundle
Elasticsearch PHP integration for your Symfony project using Elastica.
Stars: ✭ 1,142 (+1197.73%)
Mutual labels:  elasticsearch, symfony, symfony-bundle
Sylius
Open Source eCommerce Platform on Symfony
Stars: ✭ 6,598 (+7397.73%)
Mutual labels:  ecommerce, symfony, symfony-bundle
Minkbundle
Mink library integration bundle for Symfony2
Stars: ✭ 64 (-27.27%)
Mutual labels:  symfony, symfony-bundle
Platform
Shopware 6 is an open source eCommerce platform realised by the ideas and the spirit of its community.
Stars: ✭ 1,267 (+1339.77%)
Mutual labels:  ecommerce, symfony
Sonatacachebundle
This bundle provides caching services
Stars: ✭ 66 (-25%)
Mutual labels:  symfony, symfony-bundle
Cronos Bundle
Easy update your crontab by using @cron annotations in Symfony commands.
Stars: ✭ 73 (-17.05%)
Mutual labels:  symfony, symfony-bundle
Fmbbcodebundle
🔠 BBCode bundle for Symfony projects
Stars: ✭ 56 (-36.36%)
Mutual labels:  symfony, symfony-bundle
Elasticsearch Learning To Rank
Plugin to integrate Learning to Rank (aka machine learning for better relevance) with Elasticsearch
Stars: ✭ 1,147 (+1203.41%)
Mutual labels:  elasticsearch, elasticsearch-plugin
Dms Filter Bundle
Provides a FilterService for Symfony to allow users to implement input filtering in entities using Annotations
Stars: ✭ 74 (-15.91%)
Mutual labels:  symfony, symfony-bundle
Featureflagsbundle
Symfony2 Bundle to implement Feature Flags to your Application
Stars: ✭ 63 (-28.41%)
Mutual labels:  symfony, symfony-bundle
Lexikcurrencybundle
This Symfony2 bundle provide a service and a Twig extension to convert and display currencies.
Stars: ✭ 59 (-32.95%)
Mutual labels:  symfony, symfony-bundle
Pugxautocompleterbundle
Add an autocomplete field to your Symfony forms
Stars: ✭ 83 (-5.68%)
Mutual labels:  symfony, symfony-bundle
Pugxgeneratorbundle
An enhancement of SensioGeneratorBundle
Stars: ✭ 58 (-34.09%)
Mutual labels:  symfony, symfony-bundle
Neo4j Symfony
Symfony Bundle for the Neo4j Graph Database
Stars: ✭ 69 (-21.59%)
Mutual labels:  symfony, symfony-bundle
Sonataclassificationbundle
Symfony SonataClassificationBundle
Stars: ✭ 76 (-13.64%)
Mutual labels:  symfony, symfony-bundle
Knpmenubundle
Object Oriented menus for your Symfony project.
Stars: ✭ 1,242 (+1311.36%)
Mutual labels:  symfony, symfony-bundle
Dictionarybundle
Are you often tired to repeat static choices like gender or civility in your apps ?
Stars: ✭ 79 (-10.23%)
Mutual labels:  symfony, symfony-bundle
Fosoauthserverbundle
A server side OAuth2 Bundle for Symfony
Stars: ✭ 1,068 (+1113.64%)
Mutual labels:  symfony, symfony-bundle


About us

At BitBag we do believe in open source. However, we are able to do it just beacuse of our awesome clients, who are kind enough to share some parts of our work with the community. Therefore, if you feel like there is a possibility for us working together, feel free to reach us out. You will find out more about our professional services, technologies and contact details at https://bitbag.io/.

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.

Demo

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

Installation

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.

Note: This Plugin currently supports ElasticSearch 5.3.x up to 6.8.x. ElasticSearch ^7.x is not currently supported.

$ 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

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

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

# config/routes.yaml

bitbag_sylius_elasticsearch_plugin:
    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

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

...and update installed assets with the following command:

$ bin/console assets:install

...and remove the default ElasticSearch index (app) defined by FOSElasticaBundle in config/packages/fos_elastica.yaml:


fos_elastica:
    clients:
        default: { host: localhost, port: 9200 }
    indexes:
        app: ~

should become:


fos_elastica:
    clients:
        default: { host: localhost, port: 9200 }

In the end, with an 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.

Usage

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:

parameters:
    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).

Reindexing

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:

fos_elastica:
    indexes:
        bitbag_attribute_taxons:
            types:
                default:
                    persistence:
                        listener:
                            insert: true
                            update: false
                            delete: true

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

Site-wide search

This plugin offers a site-wide search feature as well. You have a search box field where you query all products indexed on ElasticSearch. When you enter a query in the search box the results will appear in the search results page.

You can also add search facets (a.k.a. filters) to your search results page. To do so you have to add facets to the bitbag_sylius_elasticsearch_plugin.facet.registry service (see an example of this service definition here). A facet is a service which implements the BitBag\SyliusElasticsearchPlugin\Facet\FacetInterface. You can implement your own facets from scratch or you can decorate one of the basic facet implementation included in this plugin, which are:

  • 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.

You can see an example of the definition of all of these facets here.

Changing default pagination limits

If you want to change default pagination limits, set this parameters:

parameters:
   bitbag_es_pagination_available_page_limits: [9, 18, 36]
   bitbag_es_pagination_default_limit: 9

Customization

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

Testing

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

Contribution

Learn more about our contribution workflow on http://docs.sylius.org/en/latest/contributing/.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].