tavy315/sylius-sales-representatives-plugin

Sylius plugin for managing sales representatives.

v0.2.3 2022-02-03 23:26 UTC

This package is auto-updated.

Last update: 2024-04-29 04:27:28 UTC


README

Latest Version Latest Unstable Version Software License Build Status

This plugin for Sylius allows you to manage sales representatives.

Supports Doctrine ORM driver only.

Screenshots

Sales Representatives:

Screenshot showing admin sales representatives

Customer:

Screenshot showing admin customer

Installation

Step 1: Install the plugin

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-sales-representatives-plugin

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the plugin

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\SyliusSalesRepresentativesPlugin\Tavy315SyliusSalesRepresentativesPlugin::class => ['all' => true],
];

Step 3: Configure the plugin

# config/packages/tavy315_sylius_sales_representatives.yaml

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

Step 4: Customize models

Read more about Sylius models customization here.

Customize your Customer model

Add a Tavy315\SyliusSalesRepresentativesPlugin\Model\Customer\SalesRepresentativeTrait 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\SyliusSalesRepresentativesPlugin\Model\Customer\SalesRepresentativeAwareInterface;
    use Tavy315\SyliusSalesRepresentativesPlugin\Model\Customer\SalesRepresentativeTrait;
      
    /**
     * @ORM\Entity
     * @ORM\Table(name="sylius_customer")
     */
    class Customer extends BaseCustomer implements SalesRepresentativeAwareInterface
    {
        use SalesRepresentativeTrait;
    }

Step 5: Update your database schema

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

Usage

From now, you can attach a sales representative to any customer; our use case is to send a copy of the order confirmation email when customer makes an order.