Fixed duplicating items on history sync

This commit is contained in:
Almaz Bazarov 2024-07-02 13:19:08 +02:00
parent 25002a634f
commit effc4759c4

View file

@ -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)) {