@@ -0,0 +1,57 @@ | |||
<?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; | |||
} | |||
} |
@@ -137,8 +137,6 @@ trait AdminControllerTrait | |||
$filters | |||
); | |||
//TODO Gérer depuis les événements | |||
if ($this->isInstanceOf(FilterMerchantInterface::class)) { | |||
$queryBuilder->andWhereMerchant('entity', $this->get(MerchantResolver::class)->getCurrent()); | |||
} |
@@ -23,6 +23,7 @@ use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer; | |||
use Lc\CaracoleBundle\Container\Product\ProductCategoryContainer; | |||
use Lc\CaracoleBundle\Container\Product\ProductContainer; | |||
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer; | |||
use Lc\CaracoleBundle\Container\Product\ProductFamilySectionPropertyContainer; | |||
use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer; | |||
use Lc\CaracoleBundle\Container\Reduction\ReductionCatalogContainer; | |||
use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer; | |||
@@ -40,7 +41,6 @@ use Lc\CaracoleBundle\Model\User\UserMerchantInterface; | |||
use Lc\CaracoleBundle\Model\User\VisitorInterface; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||
use Lc\CaracoleBundle\Resolver\VisitorResolver; | |||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Solver\Setting\SettingSolver; | |||
@@ -87,6 +87,7 @@ trait ControllerTrait | |||
UserPointSaleContainer::class => UserPointSaleContainer::class, | |||
VisitorContainer::class => VisitorContainer::class, | |||
DistributionContainer::class => DistributionContainer::class, | |||
ProductFamilySectionPropertyContainer::class => ProductFamilySectionPropertyContainer::class, | |||
] | |||
); | |||
} |
@@ -2,13 +2,20 @@ | |||
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\Dto\EntityDto; | |||
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use Lc\CaracoleBundle\Container\Order\OrderShopContainer; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||
use Lc\CaracoleBundle\Field\Address\AddressField; | |||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||
use Lc\SovBundle\Controller\AbstractAdminController; | |||
@@ -22,6 +29,25 @@ abstract class ProductFamilyAdminController extends AbstractAdminController | |||
{ | |||
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) | |||
{ | |||
$productFamily = $context->getEntity()->getInstance(); |
@@ -0,0 +1,30 @@ | |||
<?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; | |||
} | |||
} |
@@ -20,8 +20,7 @@ use Lc\SovBundle\Model\File\FileInterface; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class ProductFamilyModel extends AbstractFullEntity implements ProductPropertyInterface, PriceInterface, | |||
FilterSectionInterface, ProductFamilyInterface | |||
abstract class ProductFamilyModel extends AbstractFullEntity implements ProductPropertyInterface, PriceInterface, ProductFamilyInterface | |||
{ | |||
use ProductPropertyTrait; | |||
@@ -311,10 +310,9 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
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"}) | |||
@@ -332,18 +330,6 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
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 | |||
{ | |||
return $this->activeProducts; | |||
@@ -804,4 +790,34 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
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; | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Model\Product; | |||
interface ProductFamilySectionPropertyInterface | |||
{ | |||
} |
@@ -0,0 +1,59 @@ | |||
<?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; | |||
} | |||
} |
@@ -10,6 +10,7 @@ use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface; | |||
use Lc\CaracoleBundle\Model\Setting\SectionSettingInterface; | |||
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | |||
use Lc\SovBundle\Model\Site\NewsInterface; | |||
@@ -94,6 +95,11 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant | |||
*/ | |||
protected $isCommon; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface", mappedBy="section") | |||
*/ | |||
protected $productFamilySectionProperties; | |||
public function __construct() | |||
{ | |||
$this->productFamilies = new ArrayCollection(); | |||
@@ -104,6 +110,7 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant | |||
$this->pages = new ArrayCollection(); | |||
$this->settings = new ArrayCollection(); | |||
$this->openings = new ArrayCollection(); | |||
$this->productFamilySectionProperties = new ArrayCollection(); | |||
} | |||
public function __toString() | |||
@@ -413,4 +420,34 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant | |||
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; | |||
} | |||
} |
@@ -5,24 +5,46 @@ namespace Lc\CaracoleBundle\Repository\Product; | |||
use Knp\Component\Pager\PaginatorInterface; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | |||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||
class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
use SectionRepositoryQueryTrait; | |||
//use SectionRepositoryQueryTrait; | |||
protected bool $isJoinProductCategories = false; | |||
protected bool $isJoinProductFamilySectionProperties = false; | |||
protected bool $isJoinProducts = false; | |||
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 | |||
{ | |||
return $this->select('count(r.id)'); | |||
return $this->select('count(pf.id)'); | |||
} | |||
public function selectProductCategories(): self |
@@ -0,0 +1,16 @@ | |||
<?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); | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
<?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); | |||
} | |||
} |
@@ -0,0 +1,34 @@ | |||
<?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; | |||
} | |||
} |
@@ -23,7 +23,7 @@ class MerchantSolver | |||
$sectionArray = []; | |||
foreach($merchant->getSections() as $section) { | |||
if($section->getStatus() === 1){ | |||
if($section->getStatus() == 1){ | |||
$sectionArray[] = $section; | |||
} | |||
} |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Solver\Product; | |||
class ProductFamilySectionPropertySolver | |||
{ | |||
} | |||
@@ -65,7 +65,7 @@ class ProductFamilySolver | |||
if ($productFamily->getTaxRate()) { | |||
return $productFamily->getTaxRate(); | |||
} else { | |||
return $productFamily->getSection()->getMerchant()->getTaxRate(); | |||
return $productFamily->getProductFamilySectionProperties()[0]->getSection()->getMerchant()->getTaxRate(); | |||
} | |||
} | |||