Download the PHP package fluffydiscord/sylius-classification-bundle without Composer
On this page you can find all versions of the php package fluffydiscord/sylius-classification-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fluffydiscord/sylius-classification-bundle
More information about fluffydiscord/sylius-classification-bundle
Files in fluffydiscord/sylius-classification-bundle
Package sylius-classification-bundle
Short Description Translatable, position-ordered classification axes assignable to Sylius product variants, with admin CRUD and an admin API.
License MIT
Informations about the package sylius-classification-bundle
Sylius Classification Bundle
Variant-level, translatable, coded classification axes for Sylius 2 — a taxonomy that Sylius core does not provide: product attributes and taxons are product-level, and product options drive the variant matrix, so a free non-matrix axis (a care symbol, a certification, a supplier tag) has no home. This plugin adds one.
- Classification — a coded, translatable axis (
code,multiple,position, free-formconfig). - ClassificationValue — a coded, translatable value belonging to one axis.
- ProductVariantClassificationValue — an assignment of a value to a
ProductVariant, single- or multi-select per axis, position-ordered.
Ships admin CRUD, an admin API (API Platform), a product-variant assignment tab, grid filters, and platform-aware migrations (PostgreSQL and MySQL/MariaDB). Every entity, repository, form and service is overridable the standard Sylius way.
Requires PHP >= 8.4 and Sylius ^2.2.
Installation
1. Require the package
2. Register the bundle
3. Import the admin routes
4. Update the database
Steps 1–4 give the taxonomy, the admin CRUD screens (under the Catalog menu by default) and the admin API, with no changes to your own entities.
5. (Optional) the product-variant assignment tab
To assign classification values to variants from the admin product-variant screen, make your ProductVariant
implement ClassificationValuesAwareInterface. The plugin maps the inverse Doctrine relation for you — you do
not edit any mapping file.
If your app already overrides ProductVariant, just add the interface, the trait, and the
initializeClassificationValues() call. Register the override under sylius_product.resources.product_variant.classes.model
if it is not already.
Admin API
The paths below are the uriTemplate values. The host's sylius_api route import prepends its prefix —
%sylius.security.api_route%, which the sylius-standard skeleton sets to /api/v2 (a host may change it) — so
on a default skeleton /admin/classifications is served at /api/v2/admin/classifications, behind the admin firewall:
| Method | Path | Purpose |
|---|---|---|
GET/POST |
/admin/classifications |
list / create axes |
GET/PUT/PATCH/DELETE |
/admin/classifications/{code} |
read / update / delete an axis |
GET/POST |
/admin/classification-values |
list / create values |
GET/PUT/PATCH/DELETE |
/admin/classification-values/{code} |
read / update / delete a value |
POST |
/admin/variant-classification-values |
assign a value to a variant |
GET/DELETE |
/admin/variant-classification-values/{id} |
read / remove one assignment |
GET |
/admin/product-variants/{code}/classification-values |
a variant's assignments |
code is write-once (absent from the update groups). Authorization is the host's — every operation sits under
the Sylius API admin firewall (%sylius.security.api_admin_regex%) and declares no security of its own.
To disable the API entirely, point its mapping at an empty directory:
Grid filter
Filter a product (or variant) grid by classification value:
Configuration
Extension points
- Entities — override
sylius_classification.resources.<name>.classes.model(and.translation.classes.model). All plugin code type-hints the interfaces, so a substitute must implement the matching*Interface. - Repositories — override
...classes.repository; the interfaces areClassificationRepositoryInterface,ClassificationValueRepositoryInterface,ProductVariantClassificationValueRepositoryInterface. - Model class in grids / DQL / forms / API — always the container parameter
%sylius_classification.model.<name>.class%, never a hardcoded FQCN, so an entity override propagates. - Services — every replaceable service is aliased by its interface (
ClassificationValueCodeDeriverInterface,ClassificationLabelResolverInterface,AssignedClassificationValueProviderInterface,RenderableClassificationProviderInterface); decorate or re-alias to replace. - Templates & layout — override the plugin's Twig via your theme, or repoint the twig-hook keys under the
sylius_classification.admin.classification[_value]prefixes.
Container autoconfiguration
The plugin relies on attribute autoconfiguration for its grid filter (#[AsFilter]), its two admin Live
Components (#[AsLiveComponent]), its autocomplete field (#[AsEntityAutocompleteField]) and its Doctrine
mapping subscriber (#[AsDoctrineListener]). If you disable autoconfiguration for third-party bundles, tag these
services by hand (sylius.grid_filter, container.service_subscriber / the UX Live Component tags,
doctrine.event_listener).
Database platforms
PostgreSQL and MySQL/MariaDB are both supported; the shipped migration branches per platform. The config
column is JSONB on PostgreSQL and JSON on MySQL. Assignment foreign keys use NO ACTION (not RESTRICT) so
that trying to delete an axis or value still assigned to a variant surfaces as Sylius's friendly "cannot delete"
flash rather than a raw 500.
Development
The plugin carries a Sylius test application under tests/Application (from sylius/test-application).
License
MIT.
All versions of sylius-classification-bundle with dependencies
api-platform/metadata Version ^4.2
api-platform/state Version ^4.2
doctrine/dbal Version ^3.9 || ^4.0
doctrine/doctrine-bundle Version ^2.13
doctrine/doctrine-migrations-bundle Version ^3.4
doctrine/orm Version ^3.3
sylius/grid-bundle Version ^1.16
sylius/resource-bundle Version ^1.14
sylius/sylius Version ^2.2
sylius/twig-hooks Version ^0.9
symfony/form Version ^7.4
symfony/string Version ^7.4
symfony/ux-autocomplete Version ^2.25
symfony/ux-live-component Version ^2.25
symfony/ux-twig-component Version ^2.25
symfony/validator Version ^7.4