Fabien Normand 3 лет назад
Родитель
Сommit
f5eb66a927
2 измененных файлов: 28 добавлений и 2 удалений
  1. +15
    -0
      Controller/ControllerTrait.php
  2. +13
    -2
      EventSubscriber/Product/UpdateProductFamilySectionPropertyEventSubscriber.php

+ 15
- 0
Controller/ControllerTrait.php Просмотреть файл

@@ -159,6 +159,11 @@ trait ControllerTrait
return $this->get(SectionResolver::class)->getCurrent(true);
}

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

public function isOutOfSection()
{
return $this->get(SectionResolver::class)->isOutOfSection();
@@ -179,6 +184,16 @@ trait ControllerTrait
);
}

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

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

+ 13
- 2
EventSubscriber/Product/UpdateProductFamilySectionPropertyEventSubscriber.php Просмотреть файл

@@ -30,11 +30,22 @@ class UpdateProductFamilySectionPropertyEventSubscriber implements EventSubscrib
$productFamilySectionProperty = $event->getEntity();

if($productFamilySectionProperty instanceof ProductFamilySectionPropertyInterface) {
$section = $productFamilySectionProperty->getSection();
if($productFamilySectionProperty->getStatus() == 1) {
$productCategoryArray = $productFamilySectionProperty->getProductFamily()->getProductCategories();
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);
}
}
}
}
}

Загрузка…
Отмена
Сохранить