|
|
@@ -149,7 +149,6 @@ class OrderShopSolver |
|
|
|
|
|
|
|
if (($productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY |
|
|
|
|| $productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT)) { |
|
|
|
|
|
|
|
if (!$quantityOrder) { |
|
|
|
$quantityAsked = $this->getQuantityOrderByProduct($orderShop, $product); |
|
|
|
} |
|
|
@@ -261,32 +260,41 @@ class OrderShopSolver |
|
|
|
|
|
|
|
public function mergeComplentaryOrderShops( |
|
|
|
OrderShopInterface $orderShop, |
|
|
|
bool $combineProducts = true |
|
|
|
bool $combineProducts = true, |
|
|
|
bool $onlySameSection = false |
|
|
|
): OrderShopInterface { |
|
|
|
$this->entityManager->refresh($orderShop); |
|
|
|
|
|
|
|
if ($this->getValidComplementaryOrderShops($orderShop)) { |
|
|
|
foreach ($this->getValidComplementaryOrderShops($orderShop) as $complementaryOrderShop) { |
|
|
|
foreach ($complementaryOrderShop->getOrderProducts() as $orderProductAdd) { |
|
|
|
$updated = false; |
|
|
|
foreach ($orderShop->getOrderProducts() as $orderProduct) { |
|
|
|
if ($combineProducts && $orderProduct->getProduct()->getId() == $orderProductAdd->getProduct( |
|
|
|
)->getId() |
|
|
|
&& (string)$orderProduct->getPrice() == (string)$orderProductAdd->getPrice() |
|
|
|
) { |
|
|
|
$orderProduct->setUpdatedOnMergeComplementaryOrderShop(true); |
|
|
|
$orderProduct->setQuantityOrder( |
|
|
|
$orderProduct->getQuantityOrder() + $orderProductAdd->getQuantityOrder() |
|
|
|
); |
|
|
|
|
|
|
|
$updated = true; |
|
|
|
|
|
|
|
if (!$onlySameSection || $complementaryOrderShop->getSection()->getId() |
|
|
|
== $orderShop->getSection()->getId()) { |
|
|
|
|
|
|
|
// @TODO : obligatoire sinon un seul orderProduct de présent |
|
|
|
$this->entityManager->refresh($complementaryOrderShop); |
|
|
|
|
|
|
|
foreach ($complementaryOrderShop->getOrderProducts() as $orderProductAdd) { |
|
|
|
$updated = false; |
|
|
|
foreach ($orderShop->getOrderProducts() as $orderProduct) { |
|
|
|
if ($combineProducts && $orderProduct->getProduct()->getId( |
|
|
|
) == $orderProductAdd->getProduct()->getId() |
|
|
|
&& (string)$orderProduct->getPrice() == (string)$orderProductAdd->getPrice() |
|
|
|
) { |
|
|
|
$orderProduct->setUpdatedOnMergeComplementaryOrderShop(true); |
|
|
|
$orderProduct->setQuantityOrder( |
|
|
|
$orderProduct->getQuantityOrder() + $orderProductAdd->getQuantityOrder() |
|
|
|
); |
|
|
|
|
|
|
|
$updated = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!$updated) { |
|
|
|
$orderProductAdd->setOnMergeComplementaryOrderShop($complementaryOrderShop); |
|
|
|
$orderProductAdd->setCreatedOnMergeComplementaryOrderShop(true); |
|
|
|
$orderShop->addOrderProduct($orderProductAdd); |
|
|
|
if (!$updated) { |
|
|
|
$orderProductAdd->setOnMergeComplementaryOrderShop($complementaryOrderShop); |
|
|
|
$orderProductAdd->setCreatedOnMergeComplementaryOrderShop(true); |
|
|
|
$orderShop->addOrderProduct($orderProductAdd); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |