Browse Source

Intégration ProductFamilySectionPrperty

packProduct
Fabien Normand 3 years ago
parent
commit
e9e0071ede
16 changed files with 359 additions and 25 deletions
  1. +57
    -0
      Container/Product/ProductFamilySectionPropertyContainer.php
  2. +0
    -2
      Controller/AdminControllerTrait.php
  3. +2
    -1
      Controller/ControllerTrait.php
  4. +26
    -0
      Controller/Product/ProductFamilyAdminController.php
  5. +30
    -0
      Factory/Product/ProductFamilySectionPropertyFactory.php
  6. +33
    -17
      Model/Product/ProductFamilyModel.php
  7. +8
    -0
      Model/Product/ProductFamilySectionPropertyInterface.php
  8. +59
    -0
      Model/Product/ProductFamilySectionPropertyModel.php
  9. +37
    -0
      Model/Section/SectionModel.php
  10. +25
    -3
      Repository/Product/ProductFamilyRepositoryQuery.php
  11. +16
    -0
      Repository/Product/ProductFamilySectionPropertyRepository.php
  12. +20
    -0
      Repository/Product/ProductFamilySectionPropertyRepositoryQuery.php
  13. +34
    -0
      Repository/Product/ProductFamilySectionPropertyStore.php
  14. +1
    -1
      Solver/Merchant/MerchantSolver.php
  15. +10
    -0
      Solver/Product/ProductFamilySectionPropertySolver.php
  16. +1
    -1
      Solver/Product/ProductFamilySolver.php

+ 57
- 0
Container/Product/ProductFamilySectionPropertyContainer.php View File

<?php

namespace Lc\CaracoleBundle\Container\Product;

use App\Definition\Field\Product\ProductFamilyFieldDefinition;
use Lc\CaracoleBundle\Builder\Product\ProductFamilyBuilder;
use Lc\CaracoleBundle\Factory\Product\ProductFamilyFactory;
use Lc\CaracoleBundle\Factory\Product\ProductFamilySectionPropertyFactory;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyRepositoryQuery;
use Lc\CaracoleBundle\Repository\Product\ProductFamilySectionPropertyRepositoryQuery;
use Lc\CaracoleBundle\Repository\Product\ProductFamilySectionPropertyStore;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore;
use Lc\CaracoleBundle\Resolver\ProductFamilyResolver;
use Lc\CaracoleBundle\Solver\Product\ProductFamilySectionPropertySolver;
use Lc\CaracoleBundle\Solver\Product\ProductFamilySolver;

class ProductFamilySectionPropertyContainer
{
protected ProductFamilySectionPropertyFactory $factory;
protected ProductFamilySectionPropertySolver $solver;
protected ProductFamilySectionPropertyRepositoryQuery $repositoryQuery;
protected ProductFamilySectionPropertyStore $store;

public function __construct(
ProductFamilySectionPropertyFactory $factory,
ProductFamilySectionPropertySolver $solver,
ProductFamilySectionPropertyRepositoryQuery $repositoryQuery,
ProductFamilySectionPropertyStore $store
)
{
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): ProductFamilySectionPropertyFactory
{
return $this->factory;
}

public function getSolver(): ProductFamilySectionPropertySolver
{
return $this->solver;
}

public function getRepositoryQuery(): ProductFamilySectionPropertyRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): ProductFamilySectionPropertyStore
{
return $this->store;
}

}

+ 0
- 2
Controller/AdminControllerTrait.php View File

$filters $filters
); );


//TODO Gérer depuis les événements

if ($this->isInstanceOf(FilterMerchantInterface::class)) { if ($this->isInstanceOf(FilterMerchantInterface::class)) {
$queryBuilder->andWhereMerchant('entity', $this->get(MerchantResolver::class)->getCurrent()); $queryBuilder->andWhereMerchant('entity', $this->get(MerchantResolver::class)->getCurrent());
} }

+ 2
- 1
Controller/ControllerTrait.php View File

use Lc\CaracoleBundle\Container\Product\ProductCategoryContainer; use Lc\CaracoleBundle\Container\Product\ProductCategoryContainer;
use Lc\CaracoleBundle\Container\Product\ProductContainer; use Lc\CaracoleBundle\Container\Product\ProductContainer;
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer; use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
use Lc\CaracoleBundle\Container\Product\ProductFamilySectionPropertyContainer;
use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer; use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer;
use Lc\CaracoleBundle\Container\Reduction\ReductionCatalogContainer; use Lc\CaracoleBundle\Container\Reduction\ReductionCatalogContainer;
use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer; use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer;
use Lc\CaracoleBundle\Model\User\VisitorInterface; use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\CaracoleBundle\Resolver\MerchantResolver; use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver; use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\CaracoleBundle\Resolver\VisitorResolver;
use Lc\CaracoleBundle\Solver\Price\PriceSolver; use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\SovBundle\Model\User\UserInterface; use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Solver\Setting\SettingSolver; use Lc\SovBundle\Solver\Setting\SettingSolver;
UserPointSaleContainer::class => UserPointSaleContainer::class, UserPointSaleContainer::class => UserPointSaleContainer::class,
VisitorContainer::class => VisitorContainer::class, VisitorContainer::class => VisitorContainer::class,
DistributionContainer::class => DistributionContainer::class, DistributionContainer::class => DistributionContainer::class,
ProductFamilySectionPropertyContainer::class => ProductFamilySectionPropertyContainer::class,
] ]
); );
} }

+ 26
- 0
Controller/Product/ProductFamilyAdminController.php View File



namespace Lc\CaracoleBundle\Controller\Product; namespace Lc\CaracoleBundle\Controller\Product;


use Doctrine\ORM\QueryBuilder;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection;
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Order\OrderShopContainer; use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait; use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Field\Address\AddressField; use Lc\CaracoleBundle\Field\Address\AddressField;
use Lc\CaracoleBundle\Resolver\SectionResolver; use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Controller\AbstractAdminController; use Lc\SovBundle\Controller\AbstractAdminController;
{ {
use AdminControllerTrait; use AdminControllerTrait;


public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder
{
$queryBuilder = parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters);

$queryBuilder->leftJoin('entity.productFamilySectionProperties', 'pfsp');
$queryBuilder->andWhereSection('pfsp', $this->getSectionCurrent());
return $queryBuilder;
}

public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
{
$responseParameters = parent::configureResponseParameters($responseParameters);

// affichage du filtre sur section
$responseParameters->set('display_switch_section', true);

return $responseParameters;
}

public function showSalesStatistic(AdminContext $context) public function showSalesStatistic(AdminContext $context)
{ {
$productFamily = $context->getEntity()->getInstance(); $productFamily = $context->getEntity()->getInstance();

+ 30
- 0
Factory/Product/ProductFamilySectionPropertyFactory.php View File

<?php

namespace Lc\CaracoleBundle\Factory\Product;

use App\Entity\Product\ProductCategory;
use App\Entity\Product\ProductFamilySectionProperty;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Context\SectionContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Factory\AbstractFactory;

class ProductFamilySectionPropertyFactory extends AbstractFactory
{

public function create(SectionInterface $section, ProductFamilyInterface $productFamily): ProductFamilySectionProperty
{
$productFamilySectionProperty = new ProductFamilySectionProperty();

$productFamilySectionProperty->setSection($section);
$productFamilySectionProperty->setProductFamily($productFamily);

$productFamilySectionProperty->setStatus(0);

return $productFamilySectionProperty;
}

}

+ 33
- 17
Model/Product/ProductFamilyModel.php View File

/** /**
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()
*/ */
abstract class ProductFamilyModel extends AbstractFullEntity implements ProductPropertyInterface, PriceInterface,
FilterSectionInterface, ProductFamilyInterface
abstract class ProductFamilyModel extends AbstractFullEntity implements ProductPropertyInterface, PriceInterface, ProductFamilyInterface
{ {
use ProductPropertyTrait; use ProductPropertyTrait;


protected $saleStatus; protected $saleStatus;


/** /**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface")
* @ORM\JoinColumn(nullable=false)
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface", mappedBy="productFamily", cascade={"persist"})
*/ */
protected $section;
protected $productFamilySectionProperties;


/** /**
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\File\FileInterface", cascade={"persist", "remove"}) * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\File\FileInterface", cascade={"persist", "remove"})
return $this->getTitle(); return $this->getTitle();
} }


public function getSection(): SectionInterface
{
return $this->section;
}

public function setSection(SectionInterface $section): self
{
$this->section = $section;

return $this;
}

public function getActiveProducts(): ?bool public function getActiveProducts(): ?bool
{ {
return $this->activeProducts; return $this->activeProducts;
return $this; return $this;
} }


/**
* @return Collection|ProductFamilySectionPropertyInterface[]
*/
public function getProductFamilySectionProperties(): Collection
{
return $this->productFamilySectionProperties;
}

public function addProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
{
if (!$this->productFamilySectionProperties->contains($productFamilySectionProperty)) {
$this->productFamilySectionProperties[] = $productFamilySectionProperty;
$productFamilySectionProperty->setProductFamily($this);
}

return $this;
}

public function removeProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
{
if ($this->productFamilySectionProperties->removeElement($productFamilySectionProperty)) {
// set the owning side to null (unless already changed)
if ($productFamilySectionProperty->getProductFamily() === $this) {
$productFamilySectionProperty->setProductFamily(null);
}
}

return $this;
}

} }

+ 8
- 0
Model/Product/ProductFamilySectionPropertyInterface.php View File

<?php

namespace Lc\CaracoleBundle\Model\Product;

interface ProductFamilySectionPropertyInterface
{

}

+ 59
- 0
Model/Product/ProductFamilySectionPropertyModel.php View File

<?php

namespace Lc\CaracoleBundle\Model\Product;

use App\Entity\Product\ProductFamily;
use App\Entity\Section\Section;
use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Extension\StatusInterface;
use Lc\SovBundle\Doctrine\Extension\StatusTrait;


/**
* @ORM\MappedSuperclass()
*/
abstract class ProductFamilySectionPropertyModel implements EntityInterface, ProductFamilySectionPropertyInterface, StatusInterface
{
use StatusTrait;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="productFamilySectionProperties")
* @ORM\JoinColumn(nullable=false)
*/
protected $section;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface", inversedBy="productFamilySectionProperties")
* @ORM\JoinColumn(nullable=false)
*/
protected $productFamily;


public function getSection(): ?Section
{
return $this->section;
}

public function setSection(?Section $section): self
{
$this->section = $section;

return $this;
}

public function getProductFamily(): ?ProductFamily
{
return $this->productFamily;
}

public function setProductFamily(?ProductFamily $productFamily): self
{
$this->productFamily = $productFamily;

return $this;
}



}

+ 37
- 0
Model/Section/SectionModel.php View File

use Lc\CaracoleBundle\Model\Order\OrderShopInterface; use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface;
use Lc\CaracoleBundle\Model\Setting\SectionSettingInterface; use Lc\CaracoleBundle\Model\Setting\SectionSettingInterface;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
use Lc\SovBundle\Model\Site\NewsInterface; use Lc\SovBundle\Model\Site\NewsInterface;
*/ */
protected $isCommon; protected $isCommon;


/**
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface", mappedBy="section")
*/
protected $productFamilySectionProperties;

public function __construct() public function __construct()
{ {
$this->productFamilies = new ArrayCollection(); $this->productFamilies = new ArrayCollection();
$this->pages = new ArrayCollection(); $this->pages = new ArrayCollection();
$this->settings = new ArrayCollection(); $this->settings = new ArrayCollection();
$this->openings = new ArrayCollection(); $this->openings = new ArrayCollection();
$this->productFamilySectionProperties = new ArrayCollection();
} }


public function __toString() public function __toString()


return $this; return $this;
} }

/**
* @return Collection|ProductFamilySectionPropertyInterface[]
*/
public function getProductFamilySectionProperties(): Collection
{
return $this->productFamilySectionProperties;
}

public function addProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
{
if (!$this->productFamilySectionProperties->contains($productFamilySectionProperty)) {
$this->productFamilySectionProperties[] = $productFamilySectionProperty;
$productFamilySectionProperty->setSection($this);
}

return $this;
}

public function removeProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
{
if ($this->productFamilySectionProperties->removeElement($productFamilySectionProperty)) {
// set the owning side to null (unless already changed)
if ($productFamilySectionProperty->getSection() === $this) {
$productFamilySectionProperty->setSection(null);
}
}

return $this;
}
} }

+ 25
- 3
Repository/Product/ProductFamilyRepositoryQuery.php View File

use Knp\Component\Pager\PaginatorInterface; use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery; use Lc\SovBundle\Repository\AbstractRepositoryQuery;


class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery
{ {
use SectionRepositoryQueryTrait;
//use SectionRepositoryQueryTrait;


protected bool $isJoinProductCategories = false; protected bool $isJoinProductCategories = false;
protected bool $isJoinProductFamilySectionProperties = false;
protected bool $isJoinProducts = false; protected bool $isJoinProducts = false;


public function __construct(ProductFamilyRepository $repository, PaginatorInterface $paginator) public function __construct(ProductFamilyRepository $repository, PaginatorInterface $paginator)
{ {
parent::__construct($repository, 'r', $paginator);
parent::__construct($repository, 'pf', $paginator);
} }


public function joinProductFamilySectionProperties(bool $addSelect = true): self
{
if (!$this->isJoinProductFamilySectionProperties) {
$this->isJoinProductFamilySectionProperties = true;

$this->leftJoin('.productFamilySectionProperties', 'pfsp');
if ($addSelect) {
$this->addSelect('pfsp');
}
}
return $this;
}

public function filterBySection(SectionInterface $section)
{
$this->joinProductFamilySectionProperties();
return $this->andWhereSection('pfsp', $section);
}


public function selectCount(): self public function selectCount(): self
{ {
return $this->select('count(r.id)');
return $this->select('count(pf.id)');
} }


public function selectProductCategories(): self public function selectProductCategories(): self

+ 16
- 0
Repository/Product/ProductFamilySectionPropertyRepository.php View File

<?php

namespace Lc\CaracoleBundle\Repository\Product;

use App\Entity\Product\Product;
use App\Entity\Product\ProductFamilySectionProperty;
use Doctrine\Persistence\ManagerRegistry;
use Lc\SovBundle\Repository\AbstractRepository;

class ProductFamilySectionPropertyRepository extends AbstractRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ProductFamilySectionProperty::class);
}
}

+ 20
- 0
Repository/Product/ProductFamilySectionPropertyRepositoryQuery.php View File

<?php

namespace Lc\CaracoleBundle\Repository\Product;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class ProductFamilySectionPropertyRepositoryQuery extends AbstractRepositoryQuery
{
use SectionRepositoryQueryTrait;

public function __construct(ProductFamilySectionPropertyRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'pfsp', $paginator);
}



}

+ 34
- 0
Repository/Product/ProductFamilySectionPropertyStore.php View File

<?php

namespace Lc\CaracoleBundle\Repository\Product;

use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\AbstractRepository;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class ProductFamilySectionPropertyStore extends AbstractRepository
{
use SectionStoreTrait;

protected ProductFamilySectionPropertyRepositoryQuery $query;

public function __construct(ProductFamilySectionPropertyRepositoryQuery $query)
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault($query): RepositoryQueryInterface
{
return $query;
}
}

+ 1
- 1
Solver/Merchant/MerchantSolver.php View File

$sectionArray = []; $sectionArray = [];


foreach($merchant->getSections() as $section) { foreach($merchant->getSections() as $section) {
if($section->getStatus() === 1){
if($section->getStatus() == 1){
$sectionArray[] = $section; $sectionArray[] = $section;
} }
} }

+ 10
- 0
Solver/Product/ProductFamilySectionPropertySolver.php View File

<?php

namespace Lc\CaracoleBundle\Solver\Product;

class ProductFamilySectionPropertySolver
{

}



+ 1
- 1
Solver/Product/ProductFamilySolver.php View File

if ($productFamily->getTaxRate()) { if ($productFamily->getTaxRate()) {
return $productFamily->getTaxRate(); return $productFamily->getTaxRate();
} else { } else {
return $productFamily->getSection()->getMerchant()->getTaxRate();
return $productFamily->getProductFamilySectionProperties()[0]->getSection()->getMerchant()->getTaxRate();
} }
} }



Loading…
Cancel
Save