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 to work together, feel free to reach out. You will find out more about our professional services, technologies, and contact details at https://bitbag.io/.
Like what we do? Want to join us? Check out our job listings on our career page. Not familiar with Symfony & Sylius yet, but still want to start with us? Join our academy!
This plugin allows you to create new products by bundling existing products together.
This open-source plugin was developed to help the Sylius community. If you have any additional questions, would like help with installing or configuring the plugin, or need any assistance with your Sylius project - let us know!
-
Require plugin with composer:
composer require bitbag/product-bundle-plugin
-
Add plugin dependencies to your
config/bundles.php
file afterSylius\Bundle\ApiBundle\SyliusApiBundle
.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; }
Mapping (Annotations) - Override bundle trait, by create new one and use it in Entity/Product/Product .
use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleInterface; use BitBag\SyliusProductBundlePlugin\Entity\ProductBundlesAwareTrait; use Doctrine\ORM\Mapping as ORM; trait ProductTrait { use ProductBundlesAwareTrait; /** * @var ProductBundleInterface * @ORM\OneToOne( * targetEntity="BitBag\SyliusProductBundlePlugin\Entity\ProductBundleInterface", * mappedBy="product", * cascade={"all"},) */ protected $productBundle; }
Mapping (XML):
# Resources/config/doctrine/Product.Product.orm.xml <?xml version="1.0" encoding="UTF-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd" > <entity name="App\Entity\Product\Product" table="sylius_product"> <one-to-one field="productBundle" target-entity="BitBag\SyliusProductBundlePlugin\Entity\ProductBundleInterface" mapped-by="product"> <cascade> <cascade-all/> </cascade> </one-to-one> </entity> </doctrine-mapping>
-
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(); } }
Mapping (Annotations) - Override bundle trait, by create new one and use it in Entity/Order/OrderItem .
use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItemInterface; use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItemsAwareTrait; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; trait OrderItemTrait { use ProductBundleOrderItemsAwareTrait; /** * @var ArrayCollection|ProductBundleOrderItemInterface[] * @ORM\OneToMany( * targetEntity="BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItemInterface", * mappedBy="orderItem", * cascade={"all"},) */ protected $productBundleOrderItems; }
Mapping (XML):
# Resources/config/doctrine/Order.OrderItem.orm.xml <?xml version="1.0" encoding="UTF-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd" > <entity name="App\Entity\Order\OrderItem" table="sylius_order_item"> <one-to-many field="productBundleOrderItems" target-entity="BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItem" mapped-by="orderItem" > <cascade> <cascade-all/> </cascade> </one-to-many> </entity> </doctrine-mapping>
-
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
-
Add 'Create/Bundle' to product grid configuration:
# config/packages/_sylius.yaml sylius_grid: grids: sylius_admin_product: actions: main: create: type: links label: sylius.ui.create options: class: primary icon: plus header: icon: cube label: sylius.ui.type links: simple: label: sylius.ui.simple_product icon: plus route: sylius_admin_product_create_simple configurable: label: sylius.ui.configurable_product icon: plus route: sylius_admin_product_create bundle: label: bitbag_sylius_product_bundle.ui.bundle icon: plus route: bitbag_product_bundle_admin_product_create_bundle
-
If you have full configuration in xml override doctrine config :
# config/packages/doctrine.yaml mappings: App: is_bundle: false type: xml dir: '%kernel.project_dir%/src/Resources/config/doctrine' prefix: 'App\Entity' alias: App
-
Finish the installation by updating the database schema and installing assets:
$ bin/console doctrine:migrations:diff $ 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
BitBag is a company of people who love what they do and do it right. We fulfill the eCommerce technology stack with Sylius, Shopware, Akeneo, and Pimcore for PIM, eZ Platform for CMS, and VueStorefront for PWA. Our goal is to provide real digital transformation with an agile solution that scales with the clients’ needs. Our main area of expertise includes eCommerce consulting and development for B2C, B2B, and Multi-vendor Marketplaces.
We are advisers in the first place. We start each project with a diagnosis of problems, and an analysis of the needs and goals that the client wants to achieve.
We build unforgettable, consistent digital customer journeys on top of the best technologies. Based on a detailed analysis of the goals and needs of a given organization, we create dedicated systems and applications that let businesses grow.
Our team is fluent in Polish, English, German and, French. That is why our cooperation with clients from all over the world is smooth.
Some numbers from BitBag regarding Sylius:
- 50+ experts including consultants, UI/UX designers, Sylius trained front-end and back-end developers,
- 120+ projects delivered on top of Sylius,
- 25+ countries of BitBag’s customers,
- 4+ years in the Sylius ecosystem.
Our services:
- Business audit/Consulting in the field of strategy development,
- Data/shop migration,
- Headless eCommerce,
- Personalized software development,
- Project maintenance and long term support,
- Technical support.
Key clients: Mollie, Guave, P24, Folkstar, i-LUNCH, Elvi Project, WestCoast Gifts.
If you need some help with Sylius development, don't be hesitated to contact us directly. You can fill the form on this site or send us an e-mail at [email protected]!
For online communication, we invite you to chat with us & other users on Sylius Slack.
We created a demo app with some useful use-cases of plugins!
Visit sylius-demo.bitbag.io to take a look at it. The admin can be accessed under
sylius-demo.bitbag.io/admin/login link and bitbag: bitbag
credentials.
Plugins that we have used in the demo:
If you need an overview of Sylius' capabilities, schedule a consultation with our expert.
To learn more about our contribution workflow and more, we encourage you to use the following resources:
This plugin's source code is completely free and released under the terms of the MIT license.
If you want to contact us, the best way is to fill the form on our website or send us an e-mail to [email protected] with your question(s). We guarantee that we answer as soon as we can!