tavy315/sylius-customer-pools-plugin

管理客户池的Sylius插件。

安装: 301

依赖者: 0

建议者: 0

安全: 0

星标: 2

关注者: 3

分支: 3

开放问题: 0

类型:sylius-plugin

v0.3.0 2022-12-02 12:29 UTC

This package is auto-updated.

Last update: 2024-08-30 01:26:20 UTC


README

Latest Version Latest Unstable Version Software License Build Status

此插件允许您管理Sylius的客户池。

仅支持Doctrine ORM驱动程序。

客户池是分配给特定渠道的客户集合。多亏了这个概念,如果您有两个渠道,每个渠道都有一个单独的客户池,那么在渠道A中有账户但未在渠道B注册的客户将无法使用他们在渠道A中指定的凭证登录渠道B(这是Sylius开源版本中的行为)。此功能允许您通过多个渠道销售,同时创建一种在完全不同的商店购物的错觉,同时您仍然有一个管理面板。

屏幕截图

客户池

Screenshot showing admin customer pools

客户

Screenshot showing admin customer

安装

步骤 1:安装插件

打开命令行控制台,进入您的项目目录,并执行以下命令以下载此插件的最新稳定版本

$ composer require tavy315/sylius-customer-pools-plugin

此命令需要您全局安装Composer,如Composer文档中的安装章节所述。

步骤 2:启用插件

然后,通过将其添加到项目中config/bundles.php文件中注册的插件/捆绑列表中来启用该插件

<?php
$bundles = [
    Tavy315\SyliusCustomerPoolsPlugin\Tavy315SyliusCustomerPoolsPlugin::class => ['all' => true],
];

步骤 3:配置插件

# config/packages/tavy315_sylius_customer_pools.yaml

imports:
    - { resource: "@Tavy315SyliusCustomerPoolsPlugin/Resources/config/app/config.yaml" }

步骤 4:自定义模型

有关Sylius模型定制的更多信息,请参阅此处

自定义您的客户模型

Tavy315\SyliusCustomerPoolsPlugin\Model\Customer\CustomerPoolTrait特性添加到您的App\Entity\Customer\Customer类中。

  • 如果您使用注解映射

    <?php 
    // src/Entity/Customer/Customer.php
    
    namespace App\Entity\Customer;
    
    use Doctrine\ORM\Mapping as ORM;
    use Sylius\Component\Core\Model\Customer as BaseCustomer;
    use Tavy315\SyliusCustomerPoolsPlugin\Model\Customer\CustomerPoolAwareInterface;
    use Tavy315\SyliusCustomerPoolsPlugin\Model\Customer\CustomerPoolTrait;
      
    /**
     * @ORM\Entity
     * @ORM\Table(name="sylius_customer")
     */
    class Customer extends BaseCustomer implements CustomerPoolAwareInterface
    {
        use CustomerPoolTrait;
    }

步骤 5:更新您的数据库模式

$ php bin/console doctrine:migrations:diff
$ php bin/console doctrine:migrations:migrate

步骤 6:将UserChecker添加到security.yaml

这将限制用户只能登录具有不同客户池设置的渠道。如果客户或当前渠道未选择客户池,则将跳过检查并允许登录。

security:
    firewalls:
        shop:
            user_checker: tavy315_sylius_customer_pools.security.user_checker

用法

从现在起,您可以为任何客户附加客户池。