This plugin for Sylius allows you to manage customer pools.
Supports Doctrine ORM driver only.
Customer Pool is a collection of Customers that is assigned to a specific channel. Thanks to this concept, if you have two channels, each of them has a separate customer pool, then customers that have accounts in channel A, and have not registered in channel B, will not be able to log in to channel B with credentials they have specified in channel A (which is the behaviour happening in Sylius open source edition). This feature allows you to sell via multiple channels, creating a illusion of shopping in completely different stores, while you still have one administration panel.
Customer Pools:
Customer:
Open a command console, enter your project directory and execute the following command to download the latest stable version of this plugin:
$ composer require tavy315/sylius-customer-pools-plugin
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Then, enable the plugin by adding it to the list of registered plugins/bundles in config/bundles.php
file of your project:
<?php
$bundles = [
Tavy315\SyliusCustomerPoolsPlugin\Tavy315SyliusCustomerPoolsPlugin::class => ['all' => true],
];
# config/packages/tavy315_sylius_customer_pools.yaml
imports:
- { resource: "@Tavy315SyliusCustomerPoolsPlugin/Resources/config/app/config.yaml" }
Read more about Sylius models customization here.
Add a Tavy315\SyliusCustomerPoolsPlugin\Model\Customer\CustomerPoolTrait
trait to your App\Entity\Customer\Customer
class.
-
If you use
annotations
mapping:<?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; }
$ php bin/console doctrine:migrations:diff
$ php bin/console doctrine:migrations:migrate
This will restrict the user to login to a Channel having different Customer Pool setup. If no Customer Pool is selected on the customer or current channel, it will skip the check and allow login.
security:
firewalls:
shop:
user_checker: tavy315_sylius_customer_pools.security.user_checker
From now, you can attach a customer pool to any customer.
vendor/bin/ecs check src
vendor/bin/phpstan analyse src