Browse Source

Modification valeur de retour de OrderShopBuilder::addOrderProduct(): array

develop
Guillaume 2 years ago
parent
commit
6bda8950b9
2 changed files with 13 additions and 12 deletions
  1. +8
    -9
      Builder/Order/OrderShopBuilder.php
  2. +5
    -3
      Controller/Order/CartController.php

+ 8
- 9
Builder/Order/OrderShopBuilder.php View File

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(

+ 5
- 3
Controller/Order/CartController.php View File

public function addOrderProduct(OrderShopInterface $orderShop, OrderProductInterface $orderProduct): void public function addOrderProduct(OrderShopInterface $orderShop, OrderProductInterface $orderProduct): void
{ {
$this->quantityOrder = $orderProduct->getQuantityOrder(); $this->quantityOrder = $orderProduct->getQuantityOrder();
$addOrderProduct = $this->getOrderShopContainer()->getBuilder()->addOrderProduct(
$orderProductArray = $this->getOrderShopContainer()->getBuilder()->addOrderProduct(
$orderShop, $orderShop,
$orderProduct $orderProduct
); );


if (isset($addOrderProduct) && $addOrderProduct && $orderProduct->getQuantityOrder() > 0) {
$this->orderProducts[] = $orderProduct;
if (is_array($orderProductArray)) {
foreach($orderProductArray as $orderProduct) {
$this->orderProducts[] = $orderProduct;
}
} }
} }



Loading…
Cancel
Save