Giter VIP home page Giter VIP logo

syliusproductbundleplugin's Introduction

BitBag SyliusProductBundlePlugin


Slack Support

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!

Table of Content


Overview


This plugin allows you to create new products by bundling existing products together.

We are here to help

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!

Installation


  1. Require plugin with composer:

    composer require bitbag/product-bundle-plugin --no-scripts
  2. Add plugin dependencies to your config/bundles.php file after Sylius\Bundle\ApiBundle\SyliusApiBundle.

        return [
         ...
        
            BitBag\SyliusProductBundlePlugin\BitBagSyliusProductBundlePlugin::class => ['all' => true ],
        ];
  3. Import required config in your config/packages/_sylius.yaml file:

    # config/packages/_sylius.yaml
    
    imports:
        ...
        
        - { resource: "@BitBagSyliusProductBundlePlugin/Resources/config/config.yml" }
  4. Import routing in your config/routes.yaml file:

    # config/routes.yaml
    ...
    
    bitbag_sylius_product_bundle_plugin:
        resource: "@BitBagSyliusProductBundlePlugin/Resources/config/routing.yml"
  5. 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 your Product entity instead of plugins ProductBundlesAwareTrait.

    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>
  6. 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 your OrderItem 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>
  7. 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
    
  8. 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
       
  9. 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
    
    
  10. Copy plugin templates into your project templates/bundles directory:

    $ cp -R vendor/bitbag/product-bundle-plugin/tests/Application/templates/bundles/* templates/bundles/
  11. Please clear application cache by running command below:

    $ bin/console cache:clear
  12. Finish the installation by updating the database schema and installing assets:

    $ bin/console doctrine:migrations:diff
    $ bin/console doctrine:migrations:migrate
  13. 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.

About us


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]!


Community


For online communication, we invite you to chat with us & other users on Sylius Slack.

Demo Sylius Shop


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:

BitBag's Plugin GitHub Sylius' Store
ACL Plugin Private. Available after the purchasing. https://plugins.sylius.com/plugin/access-control-layer-plugin/
Braintree Plugin https://github.com/BitBagCommerce/SyliusBraintreePlugin https://plugins.sylius.com/plugin/braintree-plugin/
CMS Plugin https://github.com/BitBagCommerce/SyliusCmsPlugin https://plugins.sylius.com/plugin/cmsplugin/
Elasticsearch Plugin https://github.com/BitBagCommerce/SyliusElasticsearchPlugin https://plugins.sylius.com/plugin/2004/
Mailchimp Plugin https://github.com/BitBagCommerce/SyliusMailChimpPlugin https://plugins.sylius.com/plugin/mailchimp/
Multisafepay Plugin https://github.com/BitBagCommerce/SyliusMultiSafepayPlugin
Wishlist Plugin https://github.com/BitBagCommerce/SyliusWishlistPlugin https://plugins.sylius.com/plugin/wishlist-plugin/
Sylius' Plugin GitHub Sylius' Store
Admin Order Creation Plugin https://github.com/Sylius/AdminOrderCreationPlugin https://plugins.sylius.com/plugin/admin-order-creation-plugin/
Invoicing Plugin https://github.com/Sylius/InvoicingPlugin https://plugins.sylius.com/plugin/invoicing-plugin/
Refund Plugin https://github.com/Sylius/RefundPlugin https://plugins.sylius.com/plugin/refund-plugin/

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:

License


This plugin's source code is completely free and released under the terms of the MIT license.

Contact


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!

syliusproductbundleplugin's People

Contributors

arek31 avatar bartoszwojdalowicz avatar bitbager avatar damonsson avatar dieterholvoet avatar er1z avatar gabriela-lubkowska avatar glancu avatar gracjanjozefczyk avatar jakubtobiasz avatar jcgdjob avatar krisflorq avatar leszczuu avatar liszkapawel avatar lruozzi9 avatar macbalc avatar marekrzytki avatar mateuszdyla avatar patrick477 avatar piotrszymanski2000 avatar pptasinski avatar senghe avatar szymonfilipek avatar szymonkostrubiec avatar vitse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

syliusproductbundleplugin's Issues

Is this plugin still active?

Hello,

Is this plugin still active?
If not, do you know an alternative Sylius plugin to manage sets of products?

Thanks

The association BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItem#orderItem refers to the inverse side field App\Entity\Order\OrderItem#productBundleOrderItems which does not exist

When looking through the Symfony Profiler for an unrelated issue, I noticed an error in the Entities Mapping section of the Doctrine pane:

The association BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItem#orderItem refers to the inverse side field App\Entity\Order\OrderItem#productBundleOrderItems which does not exist

Doctrine conflict

Hello guys,

I want to install this package, but am unable to do so with the latest version because of this part added to composer.json :

"conflict": {
    "doctrine/orm": "^2.10.0"
},

I currently have version 2.11.1 of doctrine/orm installed and I want to avoid the downgrade to 2.9.

Any way to know why this package conflicts with doctrine/orm:^2.10.0 ?

Not support promotion

Step to reproduce

  1. Create a promotion with cart total reach $500 could enjoy $10 discount.
  2. Add bundle item with item total > $500
  3. apply discount code
  4. invalid code

Install problem

Hi, I tried to install the package on Sylius v1.9.0, but got this message:
image

After using -W flag, installation is successful, but I no longer have the "src/Kernel.php" file, just 2 directories: "src/Entity" and "src/Migrations" so now I have to install Sylius from scratch.

Does anyone know why is this happening?

PS: I have the same problem when I try to install Sylius ShopAPI plugin.

Windows 10 Pro
Sylius: 1.9.0
Composer: 2.0.13
PHP: 7.4.9

Thanks!

Entity ProductBundleOrderItem mapping is invalid

I'm trying to install the CMSPlugin and i get an doctrine error, making a bin/console doctrine:schema:validate i get the following error:

 [FAIL] The entity-class BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItem mapping is invalid:
 * The association BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItem#orderItem refers to the inverse side field App\Entity\Order\OrderItem#productBundleItems which does not exist.

I review the src\Entity\OrderItem class that have the extension and i see that the protected value is:

    /**
     * @var Collection|ProductBundleOrderItemInterface[]
     *
     * @OneToMany(
     *     targetEntity="BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItemInterface",
     *     mappedBy="orderItem",
     *     cascade={"ALL"}
     * )
     */
    protected $productBundleOrderItems;

I will do some tests, but it don't allowme to install other plugins.

AddProductBundleToCartCommand serialization config not compatible with constructor fields

Affected SyliusProductBundlePlugin version: v2.2.0
Sylius version: v1.12.5
PHP version: 8.0.23

Describe the issue

When using the API-route [PATCH] /api/v2/shop/product-bundles/{id}/add-to-cart with the following body (as stipulated by AddProductBundleToCartCommand):

{
    "orderId": 1,
    "productCode": "example-bundle",
    "quantity": 1
}

I get the following response:
400 Bad Request

{
    "code": 400,
    "message": "Cannot create an instance of \"BitBag\\SyliusProductBundlePlugin\\Command\\AddProductBundleToCartCommand\" from serialized data because its constructor requires parameter \"orderId\" to be present."
}

The serialization file AddProductBundleToCartCommand.xml specifies two fields to be deserialized: orderToken and quantity. But the AddProductBundleToCartCommand requires orderId, productCode, and quantity.

Observation

While the serialization file is wrong, it proposes a better way to define the command-object. Since the route already contains an ID for the product-bundle, the productCode field is not necessary. orderToken is also a better way to associate the add of a bundle to a cart as that follows the convention of Sylius checkout API.

Possible solutions

  1. Reconfigure the serialization so the fields orderId, productCode, and quantity is associated with the group 'shop:product_bundle:add_to_cart'
  2. Redefine the command-file and how it is used

Product bundle Item dont show in Front page detail product

Hello,

I have installed “SyliusProductBundlePlugin” in these versions:

sylius-v1.10/PHP7.4/SF4.4
sylius-v1.11/PHP8.1/SF5.4.

I use these plugin to do a list of products, the plugin is working perfectly in the BO but when I try it in the front-end product show, it doesn’t show the list of products for this product bundle.

Could you please help me solve this issue?

product variants are not saved

Hello,

I have installed “SyliusProductBundlePlugin” in these versions:

  • sylius-v1.10/PHP7.4/SF4.4
  • sylius-v1.11/PHP8.1/SF5.4.

When I create a bundle, the data of the product variants corresponding to that bundle are not saved in the database.
In addition, the bundle’s tab disappear by itself after submitting the form.

Error on installation

When I tried to install this plugin on a clean Sylius 1.7 installation and following the steps on the documentation I got the following error when
Unrecognized option "links" under "sylius_grid.grids.sylius_admin_product.actions.main.create". Available options are "enabled", "icon", "label", "options", "position", "type".

Also, could someone assist me with the doctrine XML configuration?

  • is it mandatory?
  • should I add those xmls? where?
  • how does it work given that Sylius come preconfigured with annotations

Also, it would be very helpful that you add the the missing file's name comment on the top of the file snippets ( bundles.php, product & itemOrder entities & XMLs)

Thanks!

Product variants list is always empty

@patrick477
Hi! Do I understand correctly that your plugin allows you to create a bundle-type product that consists of other products? What should I do to display the required data in the product variant field?
image

Thanks!)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.