setono / sylius-algolia-plugin
Algolia integration for your Sylius store
Fund package maintenance!
Setono
Installs: 1 135
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 0
Open Issues: 12
Type:sylius-plugin
Requires
- php: >=7.4
- algolia/algoliasearch-client-php: ^3.2
- doctrine/event-manager: ^1.1
- doctrine/orm: ^2.7
- doctrine/persistence: ^2.2
- fig/link-util: ^1.1
- liip/imagine-bundle: ^2.6
- psr/cache: ^1.0
- psr/event-dispatcher: ^1.0
- psr/link: ^1.0
- psr/log: ^1.0 || ^2.0
- setono/bot-detection-bundle: ^1.6
- setono/client-id-bundle: ^0.2
- setono/client-id-contracts: ^0.2
- setono/doctrine-object-manager-trait: ^1.1
- setono/prerender-bundle: ^0.1
- sylius/resource-bundle: ^1.6
- symfony/cache-contracts: ^2.0
- symfony/config: ^4.4 || ^5.0
- symfony/console: ^4.4 || ^5.0
- symfony/dependency-injection: ^4.4 || ^5.0
- symfony/event-dispatcher: ^4.4 || ^5.0
- symfony/http-foundation: ^4.4 || ^5.0.7
- symfony/http-kernel: ^4.4 || ^5.1.5
- symfony/messenger: ^4.4 || ^5.0
- symfony/routing: ^4.4 || ^5.0
- symfony/serializer: ^4.4 || ^5.0
- symfony/string: ^5.0
- symfony/validator: ^4.4 || ^5.0
- twig/twig: ^2.14
- webmozart/assert: ^1.10
Requires (Dev)
- api-platform/core: ^2.6
- doctrine/dbal: ^2.13
- friendsofsymfony/oauth-server-bundle: >2.0.0-alpha.0 ^2.0@dev
- lexik/jwt-authentication-bundle: ^2.15
- matthiasnoback/symfony-config-test: ^4.3
- matthiasnoback/symfony-dependency-injection-test: ^4.3
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.16.1
- psalm/plugin-symfony: ^3.1
- roave/security-advisories: dev-latest
- setono/code-quality-pack: ^2.1.3
- sylius/admin-api-bundle: 1.10-RC.2
- sylius/sylius: ~1.10.13
- symfony/debug-bundle: ^4.4 || ^5.0
- symfony/dotenv: ^4.4 || ^5.0
- symfony/intl: ^4.4 || ^5.0
- symfony/maker-bundle: ^1.34
- symfony/property-info: ^4.4 || ^5.0
- symfony/web-profiler-bundle: ^4.4 || ^5.0
- symfony/webpack-encore-bundle: ^1.14
This package is auto-updated.
Last update: 2024-11-18 08:35:49 UTC
README
Use Algolia search and recommendations in your Sylius store.
Installation
composer require setono/sylius-algolia-plugin
Import configuration
# config/packages/setono_sylius_algolia.yaml imports: - { resource: "@SetonoSyliusAlgoliaPlugin/Resources/config/app/config.yaml" } setono_sylius_algolia: credentials: app_id: '%env(ALGOLIA_APP_ID)%' search_only_api_key: '%env(ALGOLIA_SEARCH_ONLY_API_KEY)%' admin_api_key: '%env(ALGOLIA_ADMIN_API_KEY)%' indexes: products: document: 'Setono\SyliusAlgoliaPlugin\Document\Product' resources: [ 'sylius.product' ] taxons: document: 'Setono\SyliusAlgoliaPlugin\Document\Taxon' resources: [ 'sylius.taxon' ] search: indexes: - 'products'
In your .env.local
add your parameters:
###> setono/sylius-algolia-plugin ### ALGOLIA_APP_ID=YOUR_APPLICATION_ID ALGOLIA_ADMIN_API_KEY=YOUR_ADMIN_API_KEY ALGOLIA_SEARCH_ONLY_API_KEY=YOUR_SEARCH_ONLY_KEY ###< setono/sylius-algolia-plugin ###
Import routing
# config/routes/setono_sylius_algolia.yaml setono_sylius_algolia: resource: "@SetonoSyliusAlgoliaPlugin/Resources/config/routes.yaml"
or if your app doesn't use locales:
# config/routes/setono_sylius_algolia.yaml setono_sylius_algolia: resource: "@SetonoSyliusAlgoliaPlugin/Resources/config/routes_no_locale.yaml"
Move plugin class in your bundles.php
Move the plugin at the top of your bundles list, else you might have an exception like You have requested a non-existent parameter "setono_sylius_algolia.cache.adapter"
<?php $bundles = [ Setono\SyliusAlgoliaPlugin\SetonoSyliusAlgoliaPlugin::class => ['all' => true], // ... ];
Implement the IndexableInterface
in your configured indexable resources
You have to implement the Setono\SyliusAlgoliaPlugin\Model\IndexableInterface
in the indexable resources you
configured in setono_sylius_algolia.indexable_resources
. In a typical Sylius application for the Product
entity
it could look like this:
<?php declare(strict_types=1); namespace App\Entity\Product; use Doctrine\ORM\Mapping as ORM; use Setono\SyliusAlgoliaPlugin\Model\IndexableAwareTrait; use Setono\SyliusAlgoliaPlugin\Model\IndexableInterface; use Sylius\Component\Core\Model\Product as BaseProduct; /** * @ORM\Entity * @ORM\Table(name="sylius_product") */ class Product extends BaseProduct implements IndexableInterface { use IndexableAwareTrait; }
Implement the IndexableResourceRepositoryInterface
in applicable repositories
The configured indexable resources' associated repositories has to implement the Setono\SyliusAlgoliaPlugin\Repository\IndexableResourceRepositoryInterface
.
If you're configuring the sylius.product
there is a trait available you can use: Setono\SyliusAlgoliaPlugin\Repository\ProductRepositoryTrait
.
Usage
TODO