umanit / sylius-product-variant-attribute-plugin
Plugin for Sylius to add attributes on product variants.
Installs: 19 038
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 6
Forks: 5
Open Issues: 0
Type:sylius-plugin
Requires
- php: ^7.4 || ^8.0
- sylius/sylius: ^1.9.0 || ^1.10.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
- 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
- friendsofsymfony/oauth-server-bundle: ^1.6 || >2.0.0-alpha.0 ^2.0@dev
- phpspec/phpspec: ^7.0
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: 0.12.85
- phpstan/phpstan-doctrine: 0.12.33
- phpstan/phpstan-strict-rules: ^0.12.0
- phpstan/phpstan-webmozart-assert: 0.12.12
- phpunit/phpunit: ^9.5
- sensiolabs/security-checker: ^6.0
- sylius-labs/coding-standard: ^4.0
- symfony/browser-kit: ^4.4 || ^5.2
- symfony/debug-bundle: ^4.4 || ^5.2
- symfony/dotenv: ^4.4 || ^5.2
- symfony/intl: ^4.4 || ^5.2
- symfony/web-profiler-bundle: ^4.4 || ^5.2
- vimeo/psalm: 4.7.1
This package is auto-updated.
Last update: 2024-11-14 00:34:40 UTC
README
UmanIT
Sylius Product Variant Attribute Plugin
Add attributes on your products variants.
Install
Install the plugin with composer
$ composer require umanit/sylius-product-variant-attribute-plugin
Register the plugin to your config/bundles.php
<?php return [ // ... Umanit\SyliusProductVariantAttributePlugin\UmanitSyliusProductVariantAttributePlugin::class => ['all' => true], ];
Import the configuration file, for example in config/packages/umanit_sylius_product_variant_attribute_plugin.yaml
imports: - { resource: '@UmanitSyliusProductVariantAttributePlugin/Resources/config/config.yaml' }
Import the routing file, for example in config/routes/sylius_admin.yaml
umanit_sylius_product_variant_attribute_plugin: resource: '@UmanitSyliusProductVariantAttributePlugin/Resources/config/admin_routing.yaml' prefix: /admin
Update your ProductVariant
entity by implementing the ProductVariantInterface
and using the ProductVariantTrait
<?php declare(strict_types=1); namespace App\Entity\Product; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Core\Model\ProductVariant as BaseProductVariant; use Sylius\Component\Product\Model\ProductVariantTranslationInterface; use Umanit\SyliusProductVariantAttributePlugin\Entity\ProductVariantInterface; use Umanit\SyliusProductVariantAttributePlugin\Entity\ProductVariantTrait; /** * @ORM\Entity * @ORM\Table(name="sylius_product_variant") */ class ProductVariant extends BaseProductVariant implements ProductVariantInterface { use ProductVariantTrait { __construct as attributesConstruct; } public function __construct() { parent::__construct(); $this->attributesConstruct(); } protected function createTranslation(): ProductVariantTranslationInterface { return new ProductVariantTranslation(); } }
Finally, don't forget to update your database!
php bin/console doctrine:migrations:diff php bin/console doctrine:migrations:migrate
Usage
Like in product edition, variants now has an Attributes
tab in which you can add attributes. The operation and
possibilities are the same as with the existing attributes.
The variant attributes list differ from the existing one used for products. A new entry is added to the Catalog
menu
in order to manage this new list.
By default, the existing entry Attributes
is renamed to Products attributes
. You can change this behaviour by
defining the following configuration:
umanit_sylius_product_variant_attribute_plugin: rename_product_attribute_menu_entry: false