|
|
|
|
|
|
|
|
OrderShopInterface $orderShop, |
|
|
OrderShopInterface $orderShop, |
|
|
OrderProductInterface $orderProductAdd, |
|
|
OrderProductInterface $orderProductAdd, |
|
|
bool $persist = true |
|
|
bool $persist = true |
|
|
): bool { |
|
|
|
|
|
$return = false; |
|
|
|
|
|
|
|
|
): ?array { |
|
|
|
|
|
$orderProductAddedArray = []; |
|
|
|
|
|
|
|
|
$orderProductAdd->setOrderShop($orderShop); |
|
|
$orderProductAdd->setOrderShop($orderShop); |
|
|
|
|
|
|
|
|
if ($this->orderShopSolver->isOrderProductAvailableAddCart($orderProductAdd, $orderShop)) { |
|
|
if ($this->orderShopSolver->isOrderProductAvailableAddCart($orderProductAdd, $orderShop)) { |
|
|
if ($orderProductAdd->getQuantityOrder() > 0) { |
|
|
if ($orderProductAdd->getQuantityOrder() > 0) { |
|
|
|
|
|
$orderProductAddedArray[] = $orderProductAdd; |
|
|
$updated = false; |
|
|
$updated = false; |
|
|
|
|
|
|
|
|
$this->orderProductBuilder->init($orderProductAdd); |
|
|
$this->orderProductBuilder->init($orderProductAdd); |
|
|
|
|
|
|
|
|
//TODO vérifier ma modif ici |
|
|
|
|
|
if(is_null($orderProductAdd->getOrderProductReductionCatalog())) { |
|
|
if(is_null($orderProductAdd->getOrderProductReductionCatalog())) { |
|
|
// on hydrate $productFamily avec réduction |
|
|
// on hydrate $productFamily avec réduction |
|
|
$productFamily = $this->productFamilyStore->setSection($orderShop->getSection())->getOneBySlug( |
|
|
$productFamily = $this->productFamilyStore->setSection($orderShop->getSection())->getOneBySlug( |
|
|
|
|
|
|
|
|
$this->orderProductBuilder->initReductionCatalog($orderShop->getSection(), $orderProductAdd, $productFamily); |
|
|
$this->orderProductBuilder->initReductionCatalog($orderShop->getSection(), $orderProductAdd, $productFamily); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
foreach ($orderShop->getOrderProducts() as $orderProduct) { |
|
|
foreach ($orderShop->getOrderProducts() as $orderProduct) { |
|
|
if ($this->orderProductSolver->compare($orderProduct, $orderProductAdd)) { |
|
|
if ($this->orderProductSolver->compare($orderProduct, $orderProductAdd)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$updated = true; |
|
|
$updated = true; |
|
|
$return = true; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$this->entityManager->persist($orderProductAdd); |
|
|
$this->entityManager->persist($orderProductAdd); |
|
|
$this->entityManager->update($orderShop); |
|
|
$this->entityManager->update($orderShop); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$return = true; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ($persist) { |
|
|
if ($persist) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
$this->utils->addFlash('error', $textError);*/ |
|
|
$this->utils->addFlash('error', $textError);*/ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$return = false; |
|
|
|
|
|
|
|
|
if(count($orderProductAddedArray) == 0) { |
|
|
|
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $return; |
|
|
|
|
|
|
|
|
return $orderProductAddedArray; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function merge( |
|
|
public function merge( |