monsieurbiz / sylius-search-plugin
A search plugin using Elasticsearch for Sylius.
Installs: 95 844
Dependents: 0
Suggesters: 0
Security: 0
Stars: 43
Watchers: 9
Forks: 38
Open Issues: 9
Type:sylius-plugin
Requires
- php: ~7.4|~8.0
- babdev/pagerfanta-bundle: ^2.5 || ^3.0
- jacquesbh/eater: ^2.0
- jane-php/automapper-bundle: ^7.1
- jolicode/elastically: ^1.4.0
- monsieurbiz/sylius-settings-plugin: ^1.0
- sylius/sylius: >=1.9 <1.13
- symfony/messenger: ^4.4 || ^5.2 || ^6.0
Requires (Dev)
- behat/behat: ^3.6.1
- behat/mink-selenium2-driver: ^1.4
- dmore/behat-chrome-extension: ^1.3
- dmore/chrome-mink-driver: ^2.7
- doctrine/data-fixtures: ^1.4
- ergebnis/composer-normalize: ^2.5
- friends-of-behat/mink: ^1.8
- friends-of-behat/mink-browserkit-driver: ^1.4
- friends-of-behat/mink-extension: ^2.4
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/symfony-extension: ^2.1
- friends-of-behat/variadic-extension: ^1.3
- hwi/oauth-bundle: ^1.1
- lchrusciel/api-test-case: ^5.0
- matthiasnoback/symfony-config-test: ^4.2
- matthiasnoback/symfony-dependency-injection-test: ^4.1
- mikey179/vfsstream: ^1.6
- mockery/mockery: ^1.4
- pamil/prophecy-common: ^0.1
- phpmd/phpmd: @stable
- phpspec/phpspec: ^6.1 || ^7.2
- phpstan/phpstan: ^0.12.57
- phpstan/phpstan-doctrine: ^0.12.19
- phpstan/phpstan-webmozart-assert: ^0.12.7
- phpunit/phpunit: ^8.5
- psalm/plugin-mockery: ^0.3
- psr/event-dispatcher: ^1.0
- sylius-labs/coding-standard: ^3.1
- symfony/browser-kit: ^4.4 || ^5.2 || ^6.0
- symfony/debug-bundle: ^4.4 || ^5.2 || ^6.0
- symfony/dotenv: ^4.4 || ^5.2 || ^6.0
- symfony/flex: ^1.7 || ^2.2.2
- symfony/web-profiler-bundle: ^4.4 || ^5.2 || ^6.0
- v2.1.8
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- dev-master / 2.0.x-dev
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v2.0.0-RC.23
- v2.0.0-RC.22
- v2.0.0-RC.21
- v2.0.0-RC.20
- v2.0.0-RC.19
- v2.0.0-RC.18
- v2.0.0-RC.17
- v2.0.0-RC.16
- v2.0.0-RC.15
- v2.0.0-RC.14
- v2.0.0-RC.13
- v2.0.0-RC.12
- v2.0.0-RC.11
- v2.0.0-RC.10
- v2.0.0-RC.9
- v2.0.0-RC.8
- v2.0.0-RC.7
- v2.0.0-RC.6
- v2.0.0-RC.5
- v2.0.0-RC.4
- v2.0.0-RC.3
- v2.0.0-RC.2
- v2.0.0-RC.1
- 1.x-dev
- v1.0.0-RC.10
- v1.0.0-RC.9
- v1.0.0-RC.8
- v1.0.0-RC.7
- v1.0.0-RC.6
- v1.0.0-RC.5
- v1.0.0-RC.4
- v1.0.0-RC.3
- v1.0.0-RC.2
- v1.0.0-RC.1
- 0.2.6
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.0
This package is auto-updated.
Last update: 2024-03-21 07:50:48 UTC
README
Search
A search plugin for Sylius using Elastically and Jane.
Installation
Require the plugin :
composer require monsieurbiz/sylius-search-plugin="^2"
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 ###
-
Install Elasticsearch 💪. See Infrastructure below.
-
Your
ProductAttribute
andProductOption
entities need to implement theMonsieurBiz\SyliusSearchPlugin\Entity\Product\SearchableInterface
interface and use theMonsieurBiz\SyliusSearchPlugin\Model\Product\SearchableTrait
trait. Example with theProductAttribute
:
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();
-
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
) -
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.