solutiondrive / sylius-product-bundles-plugin
为可以一起销售的产品的套装进行配置的 Sylius 插件
v0.5.0
2018-04-10 09:26 UTC
Requires
- php: ^7.1
- sylius/sylius: ^1.0.4
Requires (Dev)
- behat/behat: ^3.3
- behat/mink: ^1.7
- behat/mink-browserkit-driver: ^1.3
- behat/mink-extension: ^2.2
- behat/mink-selenium2-driver: ^1.3
- friends-of-behat/context-service-extension: ^1.0
- friends-of-behat/cross-container-extension: ^1.0
- friends-of-behat/service-container-extension: ^1.0
- friends-of-behat/symfony-extension: ^1.0
- friends-of-behat/variadic-extension: ^1.0
- lakion/mink-debug-extension: ^1.2.3
- phpspec/phpspec: ^3.2
- phpstan/phpstan-shim: ^0.9.2
- phpunit/phpunit: ^5.6
- se/selenium-server-standalone: ^2.52
- solutiondrive/coding-standard: ^1.0
- symplify/easy-coding-standard: ^2.4
Conflicts
- sylius/sylius: 1.1.3 || 1.1.4
- symfony/symfony: ^3.4.7
This package is auto-updated.
Last update: 2024-09-06 09:42:13 UTC
README
Sylius 产品套装插件
安装
-
运行
composer create-project sylius/plugin-skeleton ProjectName
。 -
从插件骨架根目录,运行以下命令
$ (cd tests/Application && yarn install) $ (cd tests/Application && yarn run gulp) $ (cd tests/Application && bin/console assets:install web -e test) $ (cd tests/Application && bin/console doctrine:database:create -e test) $ (cd tests/Application && bin/console doctrine:schema:create -e test)
定义
产品套装
产品套装 是一个独立资源,与代表套装的 产品 之间有一个一对一的关系,例如在 sylius-framework 中计算结账时的价格和税。一个 产品套装 的内容组织在 产品套装插槽 中。一个产品套装可以有 1 到 n 个产品套装插槽。
产品套装插槽
产品套装插槽 代表一组客户可以切换的产品。例如,在一个足球队伍套装中,可以有一个插槽“球衣”,其中可以引用不同种类的球衣。每个 产品套装插槽 中只有一个项目是最终购买的套装的一部分。
用法
产品套装创建者
这是一个用于以编程方式创建产品套装的服务。它只会创建必要的对象。它不会为您创建产品。但如果您有想要包含在套装中的产品,可以将它们与创建的套装及其内部的插槽关联起来。
获取服务
$bundleCreator = $container->get('solutiondrive.product_bundles.product_bundle_creator');
创建您的套装
$slotOptionsFactory = new solutionDrive\SyliusProductBundlesPlugin\Factory\ProductBundleSlotOptionsFactory(); $hatSlotOptions = $slotOptionsFactory->createNewWithValues(1, 'TopHats'); $shirtSlotOptions = $slotOptionsFactory->createNewWithValues(2, 'Shirts', ['someAdditionalOption' => 'AndItsValue']); $bundleCreator->createProductBundle('YourAwesomeBundle', $prductRepresentationOfTheBundle); $bundleCreator->addSlot('YourAwsomeHats', $hatSlotOptions, $hatsToAssignToSlot); $bundleCreator->addSlot('YourAwsomeShirts', $shirtSlotOptions, $shirtsToAssignToSlot); $productBundle = $bundleCreator->getProductBundle();
固定数据
有时您可能需要快速设置环境并添加一些默认套装。您可以查看 tests/Application/app/config/fixtures.yml
文件,了解如何配置固定数据。
运行插件测试
-
PHPUnit
$ bin/phpunit
-
PHPSpec
$ bin/phpspec run
-
Behat(非 JS 场景)
$ bin/behat --tags="~@javascript"
-
Behat(JS 场景)
-
下载 Chromedriver
-
使用之前下载的 Chromedriver 运行 Selenium 服务器
$ bin/selenium-server-standalone -Dwebdriver.chrome.driver=chromedriver
-
在
localhost:8080
上运行测试应用程序的 web 服务器$ (cd tests/Application && bin/console server:run 127.0.0.1:8080 -d web -e test)
-
运行 Behat
$ bin/behat --tags="@javascript"
-
使用您的插件打开 Sylius
-
使用
test
环境$ (cd tests/Application && bin/console sylius:fixtures:load -e test) $ (cd tests/Application && bin/console server:run -d web -e test)
-
使用
dev
环境$ (cd tests/Application && bin/console sylius:fixtures:load -e dev) $ (cd tests/Application && bin/console server:run -d web -e dev)