Skip to content

Latest commit

 

History

History
58 lines (46 loc) · 1.32 KB

01.4-customer-group.md

File metadata and controls

58 lines (46 loc) · 1.32 KB

Sylius B2B Kit

Installation

Add trait to Customer Group entity class

<?php

declare(strict_types=1);

namespace App\Entity\Customer;

use Doctrine\ORM\Mapping as ORM;
use Sylius\B2BKit\Entity\CustomerGroupAwareTrait;
use Sylius\B2BKit\Entity\CustomerGroupInterface;
use Sylius\B2BKit\Entity\CustomerGroupPricingListInterface;
use Sylius\Component\Customer\Model\CustomerGroup as BaseCustomerGroup;

/**
 * @ORM\Entity
 * @ORM\Table(name="sylius_customer_group")
 */
class CustomerGroup extends BaseCustomerGroup implements CustomerGroupInterface
{
    use CustomerGroupAwareTrait;
    
    /**
     * @ORM\ManyToOne(
     *     targetEntity="Sylius\B2BKit\Entity\CustomerGroupPricingListInterface",
     *     inversedBy="customerGroups",
     *     cascade={"all"}
     * )
     * @ORM\JoinColumn(
     *     name="pricing_list_id",
     *     referencedColumnName="id",
     *     nullable=true,
     *     onDelete="SET NULL",
     * )
     */
    protected ?CustomerGroupPricingListInterface $pricingList = null;
}

Override CustomerGroup config

# config/packages/_sylius.yaml

sylius_customer:
  resources:
    customer_group:
      classes:
        model: App\Entity\Customer\CustomerGroup
        repository: Sylius\B2BKit\Repository\CustomerGroupRepository