<?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; | |||||
} | |||||
} |
$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()); | ||||
} | } |
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, | |||||
] | ] | ||||
); | ); | ||||
} | } |
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(); |
<?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; | |||||
} | |||||
} |
/** | /** | ||||
* @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; | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\CaracoleBundle\Model\Product; | |||||
interface ProductFamilySectionPropertyInterface | |||||
{ | |||||
} |
<?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; | |||||
} | |||||
} |
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; | |||||
} | |||||
} | } |
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 |
<?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); | |||||
} | |||||
} |
<?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); | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
$sectionArray = []; | $sectionArray = []; | ||||
foreach($merchant->getSections() as $section) { | foreach($merchant->getSections() as $section) { | ||||
if($section->getStatus() === 1){ | |||||
if($section->getStatus() == 1){ | |||||
$sectionArray[] = $section; | $sectionArray[] = $section; | ||||
} | } | ||||
} | } |
<?php | |||||
namespace Lc\CaracoleBundle\Solver\Product; | |||||
class ProductFamilySectionPropertySolver | |||||
{ | |||||
} | |||||
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(); | |||||
} | } | ||||
} | } | ||||