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']); }