brille24 /sylius-special-price-plugin
为Sylius提供基于时间的特殊定价。
1.11.0
2023-03-30 17:31 UTC
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-08-30 01:55:11 UTC
README
此插件提供了一种配置,用于仅在特定日期范围内有效的价格。因此,如果您想在5月1日到4月1日之间更改产品的价格,这个插件就适合您。
安装
-
需要插件
composer require brille24/sylius-special-price-plugin
-
在您的
bundles.php
中注册插件return [ ... Brille24\SyliusSpecialPricePlugin\Brille24SyliusSpecialPricePlugin::class => ['all' => true], ];
-
导入插件配置
imports: ... - { resource: "@Brille24SyliusSpecialPricePlugin/Resources/config/config.yml" }
-
添加迁移
- 将迁移从
tests/Application/migration
复制到您的迁移位置。
- 将迁移从
-
重写产品变体实体
- 编写新类,该类将使用 ProductVariantSpecialPricableTrait 并实现 ProductVariantSpecialPricableInterface
- 在配置中重写模型类
sylius_product: resources: product_variant: classes: model: Brille24\SyliusSpecialPricePlugin\Entity\ProductVariant
-
添加映射和验证
- 映射
<!-- 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>
- 验证
<!-- ProductVariant.xml --> <constraint-mapping xmlns="https://symfony.com.cn/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>
- 映射
-
重写
SyliusAdminBundle/ProductVariant/Tab/_details.html.twig
添加以下内容
<div class="ui segment"> {% include 'Brille24SyliusSpecialPricePlugin::_specialPrice.html.twig' with { 'form': form.channelSpecialPricings } %} </div>
-
更新数据库模式
bin/console doctrine:schema:update --force
运行测试服务器
从插件根目录,运行以下命令
(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)
测试
为了运行 phpspec 测试,您需要运行命令 vendor/bin/phpspec run
。为了运行 phpunit 测试,您需要运行命令 vendor/bin/phpunit
。为了运行 behat 测试,您需要运行命令 vendor/bin/behat
。