Giter VIP home page Giter VIP logo

syliussearchplugin's Introduction

Monsieur Biz logo      Sylius logo
Monsieur Biz is a Sylius Extension Artisan partner

Search

Search Plugin license Recipe Tests Security

A search plugin for Sylius using Elastically and Jane.

Installation

Require the plugin :

composer require monsieurbiz/sylius-search-plugin="^2.0@RC"

If you are using Symfony Flex, the recipe will automatically do some actions.

For the installation without flex, follow these additional steps

Change your config/bundles.php file to add this line for the plugin declaration:

<?php

return [
    //..
    MonsieurBiz\SyliusSearchPlugin\MonsieurBizSyliusSearchPlugin::class => ['all' => true],
    Jane\Bundle\AutoMapperBundle\JaneAutoMapperBundle::class => ['all' => true],
];

Create the config file in config/packages/monsieurbiz_sylius_search_plugin.yaml:

imports:
  - { resource: "@MonsieurBizSyliusSearchPlugin/Resources/config/config.yaml" }

Create the route config file in config/routes/monsieurbiz_sylius_search_plugin.yaml:

monsieurbiz_search_plugin:
  resource: "@MonsieurBizSyliusSearchPlugin/Resources/config/routing.yaml"

Copy the override templates:

cp -Rv vendor/monsieurbiz/sylius-search-plugin/src/Resources/templates/* templates/

Finally configure plugin in your .env file by adding these lines at the end :

###> MonsieurBizSearchPlugin ###
MONSIEURBIZ_SEARCHPLUGIN_MESSENGER_TRANSPORT_DSN=doctrine://default
MONSIEURBIZ_SEARCHPLUGIN_ES_HOST=${ELASTICSEARCH_HOST:-localhost}
MONSIEURBIZ_SEARCHPLUGIN_ES_PORT=${ELASTICSEARCH_PORT:-9200}
MONSIEURBIZ_SEARCHPLUGIN_ES_URL=http://${MONSIEURBIZ_SEARCHPLUGIN_ES_HOST}:${MONSIEURBIZ_SEARCHPLUGIN_ES_PORT}/
###< MonsieurBizSearchPlugin ###

  1. Install Elasticsearch 💪. See Infrastructure below.

  2. Your ProductAttribute and ProductOption entities need to implement the MonsieurBiz\SyliusSearchPlugin\Entity\Product\SearchableInterface interface and use the MonsieurBiz\SyliusSearchPlugin\Model\Product\SearchableTrait trait. Example with the ProductAttribute:

namespace App\Entity\Product;

use Doctrine\ORM\Mapping as ORM;
+use MonsieurBiz\SyliusSearchPlugin\Entity\Product\SearchableInterface;
+use MonsieurBiz\SyliusSearchPlugin\Model\Product\SearchableTrait;
use Sylius\Component\Attribute\Model\AttributeTranslationInterface;
use Sylius\Component\Product\Model\ProductAttribute as BaseProductAttribute;

/**
 * @ORM\Entity
 * @ORM\Table(name="sylius_product_attribute")
 */
-class ProductAttribute extends BaseProductAttribute
+class ProductAttribute extends BaseProductAttribute implements SearchableInterface
{
+    use SearchableTrait;

    protected function createTranslation(): AttributeTranslationInterface
    {
        return new ProductAttributeTranslation();
  1. You need to run a diff of your doctrine's migrations: console doctrine:migrations:diff. Don't forget to run it! (console doctrine:migrations:migrate)

  2. Run the populate command.

Documentation

Documentation is available in the docs folder.

Infrastructure

The plugin was developed for Elasticsearch 7.16.x versions. You need to have analysis-icu and analysis-phonetic elasticsearch plugin installed.

Other information

Jane

We are using Jane to create a DTO (Data-transfer object).
Generated classes are on generated folder.
Jane configuration and JSON Schema are on src/Resources/config/jane folder.

To rebuild generated class during plugin development, we are using :

symfony php vendor/bin/jane generate --config-file=src/Resources/config/jane/jane-configuration.php

Elastically

The Elastically Client is configured in src/Resources/config/services.yaml file.
You can customize it in your .env file or if you want in config/services.yaml.
Analyzers and YAML mappings are on src/Resources/config/elasticsearch folder.

syliussearchplugin's People

Contributors

antiseptikk avatar armellarcier avatar atapatel avatar delyriand avatar ehibes avatar htaoufikallah avatar jacquesbh avatar jibbarth avatar lamasfoker avatar lanfisis avatar lruozzi9 avatar lucagallinari avatar manonlvnr avatar maximehuran avatar oallain avatar pyrech avatar seizan8 avatar surrok avatar tmarlyclever avatar zales0123 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.