From effc4759c40e55a6ea540cfdb18260ea1b6c9c35 Mon Sep 17 00:00:00 2001 From: Almaz Bazarov Date: Tue, 2 Jul 2024 13:19:08 +0200 Subject: [PATCH] Fixed duplicating items on history sync --- retailcrm/lib/RetailcrmHistory.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/retailcrm/lib/RetailcrmHistory.php b/retailcrm/lib/RetailcrmHistory.php index 71c1b96..4839e51 100755 --- a/retailcrm/lib/RetailcrmHistory.php +++ b/retailcrm/lib/RetailcrmHistory.php @@ -1137,10 +1137,10 @@ class RetailcrmHistory } /** + * @return bool Returns if stock of all items is enough + * * @throws PrestaShopDatabaseException * @throws PrestaShopException - * - * @return bool Returns if stock of all items is enough */ private static function createOrderDetails($crmOrder, $prestashopOrder, $isCreating = false) { @@ -1604,6 +1604,12 @@ class RetailcrmHistory { $isStockEnough = true; + if (empty($crmOrder['items'])) { + RetailcrmLogger::writeDebug(__METHOD__, 'Empty order items'); + + return $isStockEnough; + } + foreach ($prestashopOrder->getProductsDetail() as $orderItem) { foreach ($crmOrder['items'] as $key => $crmItem) { if (RetailcrmOrderBuilder::isGiftItem($crmItem)) {