urbitech / sylius-product-variant-attribute-plugin
Plugin for Sylius to add attributes on product variants.
Installs: 159
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 5
Type:sylius-plugin
Requires
- php: ^7.3
- sylius/sylius: ^1.7
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.7
- friends-of-behat/mink-browserkit-driver: ^1.4
- 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
- lakion/mink-debug-extension: ^1.2.3
- phpspec/phpspec: ^6.1
- phpstan/extension-installer: ^1.0
- phpunit/phpunit: ^8.5
- sensiolabs/security-checker: ^6.0
- sylius-labs/coding-standard: ^3.1
- symfony/browser-kit: ^4.4
- symfony/debug-bundle: ^4.4|^5.0
- symfony/dotenv: ^4.4|^5.0
- symfony/intl: ^4.4|^5.0
- symfony/web-profiler-bundle: ^4.4|^5.0
- symfony/web-server-bundle: ^4.4|^5.0
This package is auto-updated.
Last update: 2024-10-14 13:06:29 UTC
README
UmanIT
Sylius Product Variant Attribute Plugin
Add attributes on your products variants.
Install
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