At BitBag we do believe in open source. However, we are able to do it just because of our awesome clients, who are kind enough to share some parts of our work with the community. Therefore, if you feel like there is a possibility for us working together, feel free to reach us out. You will find out more about our professional services, technologies and contact details at https://bitbag.io/.
This plugin allows you to create new products by bundling existing products together.
-
Require plugin with composer:
composer require bitbag/product-bundle-plugin
-
Add plugin dependencies to your
config/bundles.php
file:return [ ... BitBag\SyliusProductBundlePlugin\BitBagSyliusProductBundlePlugin::class => ['all' => true ], ];
-
Import required config in your
config/packages/_sylius.yaml
file:# config/packages/_sylius.yaml imports: ... - { resource: "@BitBagSyliusProductBundlePlugin/Resources/config/config.yml" }
-
Import routing in your
config/routes.yaml
file:# config/routes.yaml ... bitbag_sylius_product_bundle_plugin: resource: "@BitBagSyliusProductBundlePlugin/Resources/config/routing.yml"
-
Extend
Product
(including Doctrine mapping):<?php declare(strict_types=1); namespace App\Entity\Product; use BitBag\SyliusProductBundlePlugin\Entity\ProductBundlesAwareInterface; use BitBag\SyliusProductBundlePlugin\Entity\ProductBundlesAwareTrait; use Sylius\Component\Core\Model\Product as BaseProduct; class Product extends BaseProduct implements ProductBundlesAwareInterface { use ProductBundlesAwareTrait; }
-
Extend
OrderItem
(including Doctrine mapping):<?php declare(strict_types=1); namespace App\Entity\Order; use BitBag\SyliusProductBundlePlugin\Entity\OrderItemInterface; use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItemsAwareTrait; use Sylius\Component\Core\Model\OrderItem as BaseOrderItem; class OrderItem extends BaseOrderItem implements OrderItemInterface { use ProductBundleOrderItemsAwareTrait; public function __construct() { parent::__construct(); $this->init(); } }
-
Add configuration for extended product, order item and product variant repository:
# config/packages/_sylius.yaml sylius_product: resources: product: classes: model: App\Entity\Product\Product product_variant: classes: repository: BitBag\SyliusProductBundlePlugin\Repository\ProductVariantRepository sylius_order: resources: order_item: classes: model: App\Entity\Order\OrderItem
-
Run database migration:
$ cp vendor/bitbag/product-bundle-plugin/src/Migrations/Version20210126022620.php $ bin/console doctrine:migrations:migrate
$ composer install
$ cd tests/Application
$ yarn install
$ yarn build
$ bin/console assets:install public -e test
$ bin/console doctrine:schema:create -e test
$ bin/console server:run 127.0.0.1:8080 -d public -e test
$ open http://localhost:8080
$ vendor/bin/behat
Learn more about our contribution workflow on http://docs.sylius.org/en/latest/contributing/.