bitbag / product-bundle-plugin
Product bundle for Sylius.
Installs: 50 694
Dependents: 0
Suggesters: 0
Security: 0
Stars: 20
Watchers: 7
Forks: 38
Open Issues: 7
Type:sylius-plugin
Requires
- php: ^8.0
- sylius/sylius: ~1.12.0 || ~1.13.0
- symfony/webpack-encore-bundle: ^1.12
Requires (Dev)
- ext-json: *
- behat/behat: ^3.6.1
- behat/mink-selenium2-driver: ^1.4
- bitbag/coding-standard: ^3.0
- composer/xdebug-handler: ^2.0
- dbrekelmans/bdi: ^1.1
- 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-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
- friendsofphp/php-cs-fixer: ^3.0
- lakion/mink-debug-extension: ^2.0.0
- lchrusciel/api-test-case: ^5.1
- php-http/message-factory: ^1.1
- phpspec/phpspec: ^7.0
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.8.1
- phpstan/phpstan-doctrine: ^1.3
- phpstan/phpstan-strict-rules: ^1.3.0
- phpstan/phpstan-webmozart-assert: ^1.2.0
- phpunit/phpunit: ^9.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- robertfausk/behat-panther-extension: ^1.1
- sylius-labs/coding-standard: ^4.0
- symfony/browser-kit: ^5.4 || ^6.0
- symfony/debug-bundle: ^5.4 || ^6.0
- symfony/dotenv: ^5.4 || ^6.0
- symfony/intl: ^5.4 || ^6.0
- symfony/web-profiler-bundle: ^5.4 || ^6.0
- vimeo/psalm: ^4.12
Conflicts
- behat/mink-selenium2-driver: >=1.7.0
- symfony/browser-kit: 4.1.8
- symfony/doctrine-bridge: 4.4.16
- symfony/dom-crawler: 4.1.8
- symfony/framework-bundle: 6.2.8
- symfony/routing: 4.1.8
- symfony/symfony: 4.1.8
- dev-master
- v2.4.1
- v2.4.0
- v2.3.0
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.0
- v2.0.0
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.1
- v1.0.0
- dev-feature/op-289-code-style
- dev-tests/op-289-refactor
- dev-fix/OP-315-missing-validation
- dev-fix/op-289-fix-installation-guide
- dev-feature/OP-266-configurable-bundled-products-stock-update
- dev-OP-270/Sylius_1_13_support
- dev-OP-165/plugin_update
- dev-feature/slack-notifications
- dev-OP-163-fix-product-bundle-add-to-cart-command
- dev-feature/OP-126
- dev-fix/fix_typos
- dev-OPSRC-602/fix-symfony-flex
This package is auto-updated.
Last update: 2024-12-19 10:56:54 UTC
README
BitBag SyliusProductBundlePlugin
We want to impact many unique eCommerce projects and build our brand recognition worldwide, so we are heavily involved in creating open-source solutions, especially for Sylius. We have already created over 35 extensions, which have been downloaded almost 2 million times.
You can find more information about our eCommerce services and technologies on our website: https://bitbag.io/. We have also created a unique service dedicated to creating plugins: https://bitbag.io/services/sylius-plugin-development.
Do you like our work? Would you like to join us? Check out the “Career” tab: https://bitbag.io/pl/kariera.
About Us
BitBag is a software house that implements tailor-made eCommerce platforms with the entire infrastructure—from creating eCommerce platforms to implementing PIM and CMS systems to developing custom eCommerce applications, specialist B2B solutions, and migrations from other platforms.
We actively participate in Sylius's development. We have already completed over 150 projects, cooperating with clients worldwide, including smaller enterprises and large international companies. We have completed projects for such important brands as Mytheresa, Foodspring, Planeta Huerto (Carrefour Group), Albeco, Mollie, and ArtNight.
We have a 70-person team of experts: business analysts and consultants, eCommerce developers, project managers, and QA testers.
Our services:
- B2B and B2C eCommerce platform implementations
- Multi-vendor marketplace platform implementations
- eCommerce migrations
- Sylius plugin development
- Sylius consulting
- Project maintenance and long-term support
- PIM and CMS implementations
Some numbers from BitBag regarding Sylius:
- 70 experts on board
- +150 projects delivered on top of Sylius
- 30 countries of BitBag’s customers
- 7 years in the Sylius ecosystem
- +35 plugins created for Sylius
Table of Content
Overview
The SyliusProductBundle plugin allows you to create bundles from existing products in your store. Bundles appear and behave like any other product in your store. This will allow the customer to add multiple products to the cart simultaneously. What's more, products that are sold as bundles encourage customers to meet minimum shipping spending limits - increasing the average order value compared to free shipping.
Installation
-
Require plugin with composer:
composer require bitbag/product-bundle-plugin --no-scripts
-
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\ProductBundlesAwareTrait; use BitBag\SyliusProductBundlePlugin\Entity\ProductInterface; use Sylius\Component\Core\Model\Product as BaseProduct; class Product extends BaseProduct implements ProductInterface { use ProductBundlesAwareTrait; }
Mapping (Attributes) - Override bundle trait, by create new one and use it in Entity/Product/Product .
Note. If you're using Attributes Mapping, please use your
ProductTrait
in yourProduct
entity instead of pluginsProductBundlesAwareTrait
.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 (Attributes) - Override bundle trait, by create new one and use it in Entity/Order/OrderItem .
Note. If you're using Attributes Mapping, please use your
OrderItemTrait
in yourOrderItem
entity instead of pluginsProductBundleOrderItemsAwareTrait
.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
-
Copy plugin templates into your project
templates/bundles
directory:$ cp -R vendor/bitbag/product-bundle-plugin/tests/Application/templates/bundles/* templates/bundles/
-
Please clear application cache by running command below:
$ bin/console cache:clear
-
Finish the installation by updating the database schema and installing assets:
$ bin/console doctrine:migrations:diff $ bin/console doctrine:migrations:migrate
-
Add plugin assets to your project: Import webpack config*
Testing
$ 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
Functionalities
All main functionalities of the plugin are described here.
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 hello@bitbag.io!
Demo
We created a demo app with some useful use-cases of plugins! Visit http://demo.sylius.com/ to take a look at it.
If you need an overview of Sylius' capabilities, schedule a consultation with our expert.
Additional resources for developers
To learn more about our contribution workflow and more, we encourage you to use the following resources:
- Sylius Documentation
- Sylius Contribution Guide
- Sylius Online Course
- Sylius Product Bundle Plugin Blog
License
This plugin's source code is completely free and released under the terms of the MIT license.
Contact
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! Contact us or send us an e-mail to hello@bitbag.io with your question(s).
Community
For online communication, we invite you to chat with us & other users on Sylius Slack.