pierre-brtrd / sylius-seo-plugin
Sylius SEO plugin by Dedi.
Installs: 498
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 28
Type:sylius-plugin
pkg:composer/pierre-brtrd/sylius-seo-plugin
Requires
- php: ^8.0
- sylius/mailer-bundle: ^1.8 || ^2.0@beta
- sylius/sylius: ~1.11 || ~1.12 || ~2 || ^2.1
- symfony/webpack-encore-bundle: ^2
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
- friends-of-behat/mink: ^1.8
- friends-of-behat/mink-browserkit-driver: ^1.4
- friends-of-behat/mink-debug-extension: ^2.0.0
- friends-of-behat/mink-extension: ^2.4
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.0
- friends-of-behat/symfony-extension: ^2.1
- friends-of-behat/variadic-extension: ^1.3
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.8.1
- phpstan/phpstan-doctrine: 1.3.16
- phpstan/phpstan-strict-rules: ^1.3.0
- phpstan/phpstan-webmozart-assert: ^1.2.0
- phpunit/phpunit: ^9.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- sylius-labs/coding-standard: ^4.2
- symfony/browser-kit: ^5.4 || ^6.0
- symfony/debug-bundle: ^5.4 || ^6.0
- symfony/dotenv: ^5.4 || ^6.0
- symfony/flex: ^2.2.2
- symfony/intl: ^5.4 || ^6.0
- symfony/web-profiler-bundle: ^5.4 || ^6.0
- vimeo/psalm: 4.27.0
README
Sylius Plugin SEO by Dedi
Sylius SEO plugin by Dedi. Metadata, OpenGraph and RichSnippets (Breadcrumb and Product) for all Sylius resources .
Dedi - web agency specialized in eCommerce since 2004 UX, UI, Dev, SEO, SEA
Overview
This Plugin provides an almost plug and play solution for your SEO needs. It integrates Metadata, OpenGraph and RichSnippets (Breadcrumb and Product) on all shop pages.
It provides integration for Google Analytics and Google Tag Manager through your channel configuration.
Organization Rich Snippet
The plugin now exposes an Organization schema based on the current channel. To enable it:
- Make your channel entity implement
RichSnippetChannelSubjectInterface; the providedRichSnippetChannelSubjectTraitalready handles the required getters. - Ensure the channel data (name, description, email, phone, billing address/TVA) is filled in Sylius.
- Once done, the homepage, contact, product and taxon pages will automatically include the organization JSON-LD alongside existing rich snippets.
No extra configuration or manual fetch is required: the OrganizationRichSnippetFactory is registered by default and relies on the channel resolved from the ChannelContextInterface.
Adding a custom Rich Snippet
Follow these steps to introduce a new JSON-LD block tailored to one of your business entities.
1. Make your entity a Rich Snippet subject
- Implement
RichSnippetSubjectInterface(or create a dedicated interface extending it, as done for products and channels) on the entity you want to expose. - Return a unique
getRichSnippetSubjectType()string; factories rely on this value to know which subjects they can handle. - Ensure your subject fetcher (see next step) returns an instance of that entity when the corresponding route is matched.
2. Provide a SubjectFetcher
- Implement
SubjectFetcherInterfaceto locate or build the subject for a given request. - Register the service with the
dedi_sylius_seo_plugin.rich_snippets.subject_fetchertag. TheRichSnippetContextwill iterate over all fetchers until one can serve the current request. - Reuse existing patterns: check the route in
canFromRequest()and load the entity infetchFromRequest().
3. Create a Rich Snippet factory
- Extend
AbstractRichSnippetFactory, declare the handled subject types viagetHandledSubjectTypes(), and implementbuildRichSnippet()to return an object implementingRichSnippetInterface(create a new model if needed, inspired byProductRichSnippetorChannelRichSnippet). - Inject any dependencies (router, price calculator, asset helpers, etc.) you need to build the final JSON-LD array.
- Register the factory service with the
dedi_sylius_seo_plugin.rich_snippets.factorytag so it is picked up automatically.
4. Rendered output
- Twig automatically dumps every registered snippet with the
dedi_sylius_seo_get_rich_snippets()function (src/Resources/views/Shop/Header/_richSnippets.html.twig). Once your subject fetcher and factory are in place, the JSON-LD block will appear without additional wiring. - Optionally add functional tests or manual assertions to confirm the JSON-LD output matches your expectations.

