bitbag/product-bundle-plugin 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bitbag/product-bundle-plugin

Composer 安装命令:

composer require bitbag/product-bundle-plugin

包简介

Product bundle for Sylius.

README 文档

README

BitBag SyliusProductBundlePlugin

Slack Support

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

  1. Require plugin with composer:

    composer require bitbag/product-bundle-plugin --no-scripts --with-all-dependencies
  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/config/config.yml" }
  4. Import routing in your config/routes.yaml file:

    # config/routes.yaml
    ...
    
    bitbag_sylius_product_bundle_plugin:
        resource: "@BitBagSyliusProductBundlePlugin/config/routes.yml"
  5. Extend Product(including Doctrine mapping):

    <?php 
    
    declare(strict_types=1);
    
    namespace App\Entity\Product;
    
    use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleInterface;
    use BitBag\SyliusProductBundlePlugin\Entity\ProductBundlesAwareTrait;
    use BitBag\SyliusProductBundlePlugin\Entity\ProductInterface;
    use Doctrine\ORM\Mapping as ORM;
    use Sylius\Component\Core\Model\Product as BaseProduct;
    use Sylius\Component\Product\Model\ProductTranslationInterface;
    
    #[ORM\Entity]
    #[ORM\Table(name: 'sylius_product')]
    class Product extends BaseProduct implements ProductInterface
    {
    use ProductBundlesAwareTrait;
    
        /**
         * @var ProductBundleInterface
         */
        #[ORM\OneToOne(
            targetEntity: "BitBag\SyliusProductBundlePlugin\Entity\ProductBundleInterface",
            mappedBy: "product",
            cascade: ["all"]
        )]
        protected $productBundle;
    
        protected function createTranslation(): ProductTranslationInterface
        {
            return new ProductTranslation();
        }
    }

    Mapping (XML):

    # 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\ProductBundleOrderItemInterface;
    use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItemsAwareTrait;
    use Doctrine\Common\Collections\ArrayCollection;
    use Doctrine\ORM\Mapping as ORM;
    use Sylius\Component\Core\Model\OrderItem as BaseOrderItem;
    
    #[ORM\Entity]
    #[ORM\Table(name: 'sylius_order_item')]
    class OrderItem extends BaseOrderItem implements OrderItemInterface
    {
    use ProductBundleOrderItemsAwareTrait;
    
        public function __construct()
        {
            parent::__construct();
            $this->init();
        }
    
        /**
         * @var ArrayCollection|ProductBundleOrderItemInterface[]
         */
        #[ORM\OneToMany(
            targetEntity: "BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItemInterface",
            mappedBy: "orderItem",
            cascade: ["all"]
        )]
        protected $productBundleOrderItems;
    }

    Mapping (XML):

    # 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:
                    model: App\Entity\Product\ProductVariant
                    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: "tabler:plus"
                                header:
                                    icon: cube
                                    label: sylius.ui.type
                                links:
                                    simple:
                                        label: sylius.ui.simple_product
                                        route: sylius_admin_product_create_simple
                                    configurable:
                                        label: sylius.ui.configurable_product
                                        route: sylius_admin_product_create
                                    bundle:
                                        label: bitbag_sylius_product_bundle.ui.bundle
                                        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%/config/doctrine'
                prefix: 'App\Entity'
                alias: App
    
    
  10. Copy plugin templates into your project templates/bundles directory:

    mkdir templates/bundles
    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.

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:

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.

bitbag/product-bundle-plugin 适用场景与选型建议

bitbag/product-bundle-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 80.42k 次下载、GitHub Stars 达 21, 最近一次更新时间为 2019 年 07 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「sylius」 「sylius-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 bitbag/product-bundle-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 bitbag/product-bundle-plugin 我们能提供哪些服务?
定制开发 / 二次开发

基于 bitbag/product-bundle-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 80.42k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 21
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 21
  • Watchers: 7
  • Forks: 41
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-25