From bc0469f8cf2e3d5bbfa7bc2f99e40eef5921679a Mon Sep 17 00:00:00 2001 From: Pavel Date: Thu, 30 May 2019 09:30:59 +0300 Subject: [PATCH] =?UTF-8?q?[fix]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B5=D0=BA=D0=BE=D1=80?= =?UTF-8?q?=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=B3?= =?UTF-8?q?=D1=80=D1=83=D0=B7=D0=BA=D0=B8=20=D0=B0=D0=BA=D1=86=D0=B8=D0=BE?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D1=85=20=D1=86=D0=B5=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ VERSION | 2 +- .../model/extension/retailcrm/prices.php | 26 +++++++++---------- tests/admin/ModelRetailcrmPricesAdminTest.php | 2 +- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eeb26a..4eff403 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v.3.3.4 +* Исправлен баг с некорректной выгрузкой акционных цен для товаров с характеристиками + ## v.3.3.3 * Добавлено удаление типа цены товара для неустановленных акционных цен diff --git a/VERSION b/VERSION index 619b537..a0891f5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.3.3 +3.3.4 diff --git a/src/upload/admin/model/extension/retailcrm/prices.php b/src/upload/admin/model/extension/retailcrm/prices.php index f5047fd..ab4331c 100644 --- a/src/upload/admin/model/extension/retailcrm/prices.php +++ b/src/upload/admin/model/extension/retailcrm/prices.php @@ -67,19 +67,19 @@ class ModelExtensionRetailcrmPrices extends Model foreach ($products as $product) { $specials = $this->model_catalog_product->getProductSpecials($product['product_id']); - if (!$specials) { + if ($specials) { + $productPrice = array(); + + if (is_array($specials) && count($specials)) { + $productPrice = $this->getSpecialPrice($specials); + } + + $prices = array_merge($this->getPriceRequest($product, $site, $productPrice), $prices); + } else { $productPrice = $this->getEmptyPrice(); - $prices[] = $this->getPriceRequest($product, $site, $productPrice); + $prices = array_merge($prices, $this->getPriceRequest($product, $site, $productPrice)); continue; } - - $productPrice = array(); - - if (is_array($specials) && count($specials)) { - $productPrice = $this->getSpecialPrice($specials); - } - - $prices[] = $this->getPriceRequest($product, $site, $productPrice); } return $prices; @@ -97,7 +97,7 @@ class ModelExtensionRetailcrmPrices extends Model private function getPriceRequest($product, $site, $productPrice) { $offers = $this->retailcrm->getOffers($product); - $pricesProduct = array(); + $pricesProducts = array(); foreach ($offers as $optionsString => $optionsValues) { $optionsString = explode('_', $optionsString); @@ -139,14 +139,14 @@ class ModelExtensionRetailcrmPrices extends Model } } - $pricesProduct = array( + $pricesProducts[] = array( 'externalId' => $offerId ? $product['product_id'] . '#' . $offerId : $product['product_id'], 'site' => $site, 'prices' => $price ); } - return $pricesProduct; + return $pricesProducts; } /** diff --git a/tests/admin/ModelRetailcrmPricesAdminTest.php b/tests/admin/ModelRetailcrmPricesAdminTest.php index 808e13e..78454aa 100644 --- a/tests/admin/ModelRetailcrmPricesAdminTest.php +++ b/tests/admin/ModelRetailcrmPricesAdminTest.php @@ -63,7 +63,7 @@ class ModelRetailcrmPricesAdminTest extends OpenCartTest $this->assertEquals('special2', $price['prices'][1]['code']); $this->assertEquals('special3', $price['prices'][2]['code']); $this->assertFalse($price['prices'][0]['remove']); - $this->assertFalse($price['prices'][1]['remove']); + $this->assertNotFalse($price['prices'][1]['remove']); $this->assertNotFalse($price['prices'][2]['remove']); }