brille24/sylius-customer-options-plugin 问题修复 & 功能扩展

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

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

brille24/sylius-customer-options-plugin

Composer 安装命令:

composer require brille24/sylius-customer-options-plugin

包简介

Adds product customizing to Sylius

README 文档

README

With this plugin the customer can add additional info to the product like so: Price import forms Price import forms

Installation

  • Run composer require brille24/sylius-customer-options-plugin.

  • Register the Plugin in your config/bundles.php:

return [
    //...
    Brille24\SyliusCustomerOptionsPlugin\Brille24SyliusCustomerOptionsPlugin::class => ['all' => true],
];
  • Add the config.yml to your local config/packages/_sylius.yaml:
imports:
    ...
    - { resource: "@Brille24SyliusCustomerOptionsPlugin/Resources/config/app/config.yml" }
  • Add the routing.yml to your local config/routes.yaml:
brille24_customer_options:
    resource: "@Brille24SyliusCustomerOptionsPlugin/Resources/config/app/routing.yml"

sylius_shop_ajax_cart_add_item:
  path: ajax/cart/add
  methods: [POST]
  defaults:
    _controller: sylius.controller.order_item::addAction
    _format: json
    _sylius:
      factory:
        method: createForProductWithCustomerOption
        arguments: [expr:notFoundOnNull(service('sylius.repository.product').find($productId))]
      form:
        type: Sylius\Bundle\CoreBundle\Form\Type\Order\AddToCartType
        options:
          product: expr:notFoundOnNull(service('sylius.repository.product').find($productId))
      redirect:
        route: sylius_shop_cart_summary
        parameters: {}
      flash: sylius.cart.add_item

sylius_shop_partial_cart_add_item:
  path: cart/add-item
  methods: [GET]
  defaults:
    _controller: sylius.controller.order_item::addAction
    _sylius:
      template: $template
      factory:
        method: createForProductWithCustomerOption
        arguments: [expr:notFoundOnNull(service('sylius.repository.product').find($productId))]
      form:
        type: Sylius\Bundle\CoreBundle\Form\Type\Order\AddToCartType
        options:
          product: expr:notFoundOnNull(service('sylius.repository.product').find($productId))
      redirect:
        route: sylius_shop_cart_summary
        parameters: {}
  • Copy the template overrides from the plugin directory
From: [shop_dir]/vendor/brille24/sylius-customer-options-plugin/test/Application/templates
To: [shop_dir]/templates

In order to use the customer options, you need to override the product and order item.

use Brille24\SyliusCustomerOptionsPlugin\Entity\ProductInterface;
use Brille24\SyliusCustomerOptionsPlugin\Traits\ProductCustomerOptionCapableTrait;
use Sylius\Component\Core\Model\Product as BaseProduct;

class Product extends BaseProduct implements ProductInterface {
    use ProductCustomerOptionCapableTrait {
        __construct as protected customerOptionCapableConstructor;
    }
    
     public function __construct()
    {
        parent::__construct();

        $this->customerOptionCapableConstructor();
    }
    // ...
}
use Brille24\SyliusCustomerOptionsPlugin\Entity\OrderItemInterface;
use Brille24\SyliusCustomerOptionsPlugin\Traits\OrderItemCustomerOptionCapableTrait;
use Sylius\Component\Core\Model\OrderItem as BaseOrderItem;

class OrderItem extends BaseOrderItem implements OrderItemInterface
{
    use OrderItemCustomerOptionCapableTrait {
        __construct as protected customerOptionCapableConstructor;
    }

    public function __construct()
    {
        parent::__construct();

        $this->customerOptionCapableConstructor();
    }
    // ...
}
  • If you also want default data you need to copy over the brille24_sylius_customer_options_plugin_fixtures.yaml file from the package directory and run
bin/console sylius:fixtures:load
  • Finally, generate migrations, update the database and update the translations:
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
bin/console translation:update

Things to consider

  • Saving files as customer defined values as the values are currently stored as a string in the database

Developing

When developing it is recommended to use git hooks for this just copy the docs/pre-commit to .git/hooks/pre-commit and make it executable. Then you will check your codestyle before committing.

Usage

Documentation on how to use the plugin can be found here.

brille24/sylius-customer-options-plugin 适用场景与选型建议

brille24/sylius-customer-options-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35.06k 次下载、GitHub Stars 达 48, 最近一次更新时间为 2018 年 04 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 brille24/sylius-customer-options-plugin 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 35.06k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 48
  • 点击次数: 17
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 48
  • Watchers: 6
  • Forks: 39
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-12