lupasearch / sylius-lupasearch-plugin
Installs: 13
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Type:sylius-plugin
Requires
- php: ^8.1
- lupasearch/lupasearch-php-client: >0.4.0 <1.0.0
- sylius/sylius: 1.12.* || 1.13.*
- symfony/amqp-messenger: ^6.4.0
Requires (Dev)
- dama/doctrine-test-bundle: ^6.0
- dg/bypass-finals: dev-master
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.8.1
- phpstan/phpstan-doctrine: 1.3.37
- phpstan/phpstan-phpunit: ^1.3
- phpstan/phpstan-strict-rules: ^1.3.0
- phpstan/phpstan-symfony: ^1.3
- phpstan/phpstan-webmozart-assert: ^1.2.0
- phpunit/phpunit: ^9.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- psr/http-factory: 1.0.x-dev
- sylius-labs/coding-standard: ^4.2
- symfony/browser-kit: ^6.4
- symfony/debug-bundle: ^6.4
- symfony/dotenv: ^6.4
- symfony/flex: ^2.2.2
- symfony/intl: ^6.4
- theofidry/alice-data-fixtures: ^1.6
Conflicts
- symfony/framework-bundle: 6.2.8
This package is auto-updated.
Last update: 2024-11-16 12:50:42 UTC
README
The LupaSearch Sylius plugin seamlessly integrates your Sylius store with the LupaSearch SaaS platform. This plugin handles the synchronization of product data and search configuration, ensuring your store's search functionality is always up-to-date and optimized for performance.
Compatibility
The plugin is compatible with Sylius 1.12.* and 1.13.*
Installation
NOTE: Before installation, please contact our support team at support@lupasearch.com to obtain the necessary credentials and onboarding information.
To install the LupaSearch plugin, follow these steps:
-
Install the bundle using Composer:
composer require lupasearch/sylius-lupasearch-plugin
-
Open your
bundles.php
file located in theconfig
directory of your Sylius project. -
Add the following lines at the end of the file:
// config/bundles.php return [ // ... other bundles ... LupaSearch\SyliusLupaSearchPlugin\LupaSearchSyliusLupaSearchPlugin::class => [ "all" => true, ], ];
-
Update the schema:
php bin/console doctrine:migrations:migrate
-
Clear your cache:
php bin/console cache:clear
Configuration
To start using the LupaSearch, you need to configure it first.
Environment variables
# LupaSearch environment variables
LUPASEARCH_USER_EMAIL=
LUPASEARCH_USER_PASSWORD=
LUPASEARCH_INDEX_ID=
LUPASEARCH_SEARCH_QUERY_ID=
LUPASEARCH_BATCH_SIZE_FETCH_FROM_DATABASE=100
LUPASEARCH_BATCH_SIZE_SEND=100
LUPASEARCH_MESSENGER_TRANSPORT_DSN=amqp://rabbitmquser:rabbitmqpass@rabbitmq:5672
Configuration file
Create a file named lupasearch_sylius_lupasearch.yaml
in the config/packages
directory of your Sylius project with the following content:
lupa_search_sylius_lupa_search: email: "%env(LUPASEARCH_USER_EMAIL)%" password: "%env(LUPASEARCH_USER_PASSWORD)%" index_id: "%env(LUPASEARCH_INDEX_ID)%" search_query_id: "%env(LUPASEARCH_SEARCH_QUERY_ID)%" export: batch_size_fetch_from_database: "%env(int:LUPASEARCH_BATCH_SIZE_FETCH_FROM_DATABASE)%" batch_size_send: "%env(int:LUPASEARCH_BATCH_SIZE_SEND)%"
Also, you need to add the following environment variables to your .env
file, the variables names may be different depending on your needs,
but it should be the same as in the lupasearch_sylius_lupasearch.yaml
file.
Usage
This plugin provides LupaSearch service integration to Sylius projects. It offers several commands to synchronize your data with LupaSearch.
Update Facets
The lupasearch:facets:update
command is used to synchronize your facets with LupaSearch. This command fetches all attributes and options from your Sylius project and sends them to LupaSearch as facets.
To do this, use the following command in your terminal:
bin/console lupasearch:facets:update
This command could be hooked up on a cron job to ensure that your facets are always up-to-date with your Sylius project. For example, you could set up a cron job to run this command every midnight.
❗ Please note that for this command to work, you need to have at least one facet in your search query.
Export Documents
The lupasearch:documents:export
command is used to export all enabled product variants as documents to LupaSearch. This command fetches all enabled product variants from your Sylius project and sends them to LupaSearch. To do this, use the following command in your terminal:
bin/console lupasearch:documents:export
This command could be run one time after a nightly import to your Sylius project to ensure that all your product variants are exported to LupaSearch.
❗ Please note that when using CLI (for example, Sylius catalog import), you should set isQueueForExport() to false in LupaExportContext. This will ensure that the product variants would not be put in the queue for export to LupaSearch. Instead, a good practice is to run the
lupasearch:documents:export
command after the import is finished.
Initiate Documents Export
The lupasearch:documents:export:initiate
command is used to fetch all queued catalog from the database and puts respective variants to the message queue for export to Lupa.
To do this, use the following command in your terminal:
bin/console lupasearch:documents:export:initiate
This command could be run after you have made changes to your product variants in your Sylius project. Entities associated with product variants that are updated via requests, such as through the Sylius Admin Panel or the API, get synchronized with LupaSearch upon the completion of the KernelFinishRequest. This process is managed using the ProductVariantDispatcherSubscriber class. This command is only needed if catalog updates are made in CLI context (for example during nightly imports).
❗ Please note that when using CLI (for example, Sylius catalog import), you should set isQueueForExport() to false in LupaExportContext. This will ensure that the product variants would not be put in the queue for export to LupaSearch. Instead, a good practice is to run the
lupasearch:documents:export:initiate
command after the import is finished.
❗ Currently, plugin is limited to
naming_strategy: doctrine.orm.naming_strategy.underscore
setting inconfig/packages/doctrine.yaml
configuration file to function properly.