Browse Source

Merge branch 'develop'

master
Fabien Normand 3 years ago
parent
commit
3b4366720a
2 changed files with 23 additions and 12 deletions
  1. +18
    -11
      Builder/Product/ProductCategoryBuilder.php
  2. +5
    -1
      Solver/Section/OpeningSolver.php

+ 18
- 11
Builder/Product/ProductCategoryBuilder.php View File

public function setOnlineIfOnlineProductfamily(ProductCategoryInterface $productCategory) public function setOnlineIfOnlineProductfamily(ProductCategoryInterface $productCategory)
{ {
if ($this->productCategorySolver->hasOnlineProductFamily($productCategory)) { if ($this->productCategorySolver->hasOnlineProductFamily($productCategory)) {
$productCategory->setStatus(1);
$this->entityManager->update($productCategory);
if(!$productCategory->getStatus()) {
$productCategory->setStatus(1);
$this->entityManager->update($productCategory);


$this->flashBagTranslator->add('success', 'setOnline','ProductCategory', array('%category%'=> $productCategory, '%section%'=> $productCategory->getSection()));
$this->flashBagTranslator->add('success', 'setOnline', 'ProductCategory', array('%category%' => $productCategory, '%section%' => $productCategory->getSection()));
}
// mise à jour du statut du parent // mise à jour du statut du parent
$productCategoryParent = $productCategory->getParent(); $productCategoryParent = $productCategory->getParent();
if ($productCategoryParent) { if ($productCategoryParent) {
$productCategoryParent->setStatus(1);
$this->entityManager->update($productCategoryParent);

if(!$productCategory->getStatus()) {
$productCategoryParent->setStatus(1);
$this->entityManager->update($productCategoryParent);
}
} }
} }
} }
public function setOfflineIfOfflineProductfamily(ProductCategoryInterface $productCategory) public function setOfflineIfOfflineProductfamily(ProductCategoryInterface $productCategory)
{ {
if (!$this->productCategorySolver->hasOnlineProductFamily($productCategory)) { if (!$this->productCategorySolver->hasOnlineProductFamily($productCategory)) {
$productCategory->setStatus(0);
$this->entityManager->update($productCategory);
$this->flashBagTranslator->add('info', 'setOffline','ProductCategory', array('%category%'=> $productCategory, '%section%'=> $productCategory->getSection()));
if($productCategory->getStatus()) {


$productCategory->setStatus(0);
$this->entityManager->update($productCategory);
$this->flashBagTranslator->add('info', 'setOffline', 'ProductCategory', array('%category%' => $productCategory, '%section%' => $productCategory->getSection()));
}
// mise à jour du statut du parent // mise à jour du statut du parent
$productCategoryParent = $productCategory->getParent(); $productCategoryParent = $productCategory->getParent();
if ($productCategoryParent && !$this->productCategorySolver->hasOnlineProductFamily($productCategoryParent)) { if ($productCategoryParent && !$this->productCategorySolver->hasOnlineProductFamily($productCategoryParent)) {
$productCategoryParent->setStatus(0);
$this->entityManager->update($productCategoryParent);
if($productCategory->getStatus()) {
$productCategoryParent->setStatus(0);
$this->entityManager->update($productCategoryParent);
}
} }
} }
} }

+ 5
- 1
Solver/Section/OpeningSolver.php View File

if($opening) { if($opening) {
$now = new \DateTime(); $now = new \DateTime();
if($weekDay == $now->format('N')) { if($weekDay == $now->format('N')) {
if($now < $opening->getTimeEnd()) {
$timeEnd = $opening->getTimeEnd();
$timeStart = $opening->getTimeStart();

if((($timeEnd && $now < $timeEnd) || !$timeEnd)
&& (($timeStart && $now > $timeStart) || !$timeStart) ) {
return true; return true;
} }
} }

Loading…
Cancel
Save