brille24 / sylius-special-price-plugin
Provides time based special pricing for Sylius.
Installs: 27 258
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 5
Forks: 2
Open Issues: 4
Type:sylius-plugin
Requires
- php: ^8.0
- sylius/mailer-bundle: ^1.8 || ^2.0@beta
- sylius/sylius: ^1.11
- symfony/webpack-encore-bundle: ^1.15
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
- phpspec/phpspec: ^7.2
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.8.1
- phpstan/phpstan-doctrine: 1.3.37
- 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: 5.9.0
This package is auto-updated.
Last update: 2024-10-30 02:31:56 UTC
README
This plugin provides a configuration for prices that are just active within a certain date range. So if you want to change the price for a product between the 1st May and the 1st of April, this plugin is for you.
Installation
-
Require the plugin
composer require brille24/sylius-special-price-plugin
-
Register the plugin in your
bundles.php
return [ ... Brille24\SyliusSpecialPricePlugin\Brille24SyliusSpecialPricePlugin::class => ['all' => true], ];
-
Import plugin config
imports: ... - { resource: "@Brille24SyliusSpecialPricePlugin/Resources/config/config.yml" }
-
Add migrations
- Copy migrations from
tests/Application/migration
to your desired spot for migrations.
- Copy migrations from
-
Override ProductVariant entity
- Write new class which will use ProductVariantSpecialPricableTrait and implement ProductVariantSpecialPricableInterface
- Override the models class in config
sylius_product: resources: product_variant: classes: model: Brille24\SyliusSpecialPricePlugin\Entity\ProductVariant
-
Add mapping and validation
- Mapping
<!-- ProductVariant.orm.xml --> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"> <mapped-superclass name="Your\Name\Space\ProductVariant" table="sylius_product_variant"> <one-to-many field="channelSpecialPricings" target-entity="Brille24\SyliusSpecialPricePlugin\Entity\ChannelSpecialPricingInterface" mapped-by="productVariant" orphan-removal="true"> <cascade> <cascade-all/> </cascade> </one-to-many> </mapped-superclass> </doctrine-mapping>
- Validation
<!-- ProductVariant.xml --> <constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"> <class name="Your\Name\Space\ProductVariant"> <constraint name="Brille24\SyliusSpecialPricePlugin\Validator\ProductVariantChannelSpecialPriceDateOverlapConstraint"> <option name="groups">sylius</option> </constraint> </class> </constraint-mapping>
- Mapping
-
Override
SyliusAdminBundle/ProductVariant/Tab/_details.html.twig
Add this:
<div class="ui segment"> {% include 'Brille24SyliusSpecialPricePlugin::_specialPrice.html.twig' with { 'form': form.channelSpecialPricings } %} </div>
-
Update the database schema
bin/console doctrine:schema:update --force
Running the test server
From the plugin root directory, run the following commands:
(cd tests/Application && yarn install) (cd tests/Application && yarn build) (cd tests/Application && bin/console assets:install --symlink) (cd tests/Application && bin/console doctrine:database:create) (cd tests/Application && bin/console doctrine:schema:update --force) (cd tests/Application && bin/console sylius:fixtures:load) (cd tests/Application && bin/console server:start)
Testing
In order to run the phpspec tests you need to run the command vendor/bin/phpspec run
In order to run the phpunit tests you need to run the command vendor/bin/phpunit
In order to run the behat tests you need to run the command vendor/bin/behat