Browse Source

Correctifs

packProduct
Guillaume 3 years ago
parent
commit
9ca1e105bb
2 changed files with 28 additions and 2 deletions
  1. +15
    -0
      Controller/ControllerTrait.php
  2. +13
    -2
      EventSubscriber/Product/UpdateProductFamilySectionPropertyEventSubscriber.php

+ 15
- 0
Controller/ControllerTrait.php View File

return $this->get(SectionResolver::class)->getCurrent(true); return $this->get(SectionResolver::class)->getCurrent(true);
} }


public function getSectionCurrentVisited(): ?SectionInterface
{
return $this->get(SectionResolver::class)->getCurrent(false, true);
}

public function isOutOfSection() public function isOutOfSection()
{ {
return $this->get(SectionResolver::class)->isOutOfSection(); return $this->get(SectionResolver::class)->isOutOfSection();
); );
} }


public function getCartCurrentVisited(): OrderShopInterface
{
return $this->getOrderShopContainer()->getBuilder()->createIfNotExist(
$this->getSectionCurrentVisited(),
$this->getUserCurrent(),
$this->getVisitorCurrent(),
true
);
}

public function getPriceSolver(): PriceSolver public function getPriceSolver(): PriceSolver
{ {
return $this->get(PriceSolver::class); return $this->get(PriceSolver::class);

+ 13
- 2
EventSubscriber/Product/UpdateProductFamilySectionPropertyEventSubscriber.php View File

$productFamilySectionProperty = $event->getEntity(); $productFamilySectionProperty = $event->getEntity();


if($productFamilySectionProperty instanceof ProductFamilySectionPropertyInterface) { if($productFamilySectionProperty instanceof ProductFamilySectionPropertyInterface) {
$section = $productFamilySectionProperty->getSection();
if($productFamilySectionProperty->getStatus() == 1) { if($productFamilySectionProperty->getStatus() == 1) {
$productCategoryArray = $productFamilySectionProperty->getProductFamily()->getProductCategories(); $productCategoryArray = $productFamilySectionProperty->getProductFamily()->getProductCategories();
foreach($productCategoryArray as $productCategory) { foreach($productCategoryArray as $productCategory) {
$productCategory->setStatus(1);
$this->entityManager->update($productCategory);
if($productCategory->getSection() == $section) {
// mise à jour du statut
$productCategory->setStatus(1);
$this->entityManager->update($productCategory);

// mise à jour du statut du parent
$productCategoryParent = $productCategory->getParent();
if($productCategoryParent) {
$productCategoryParent->setStatus(1);
$this->entityManager->update($productCategoryParent);
}
}
} }
} }
} }

Loading…
Cancel
Save