Merge pull request #156 from Neur0toxine/master

[fix] Исправление некорректной загрузки акционных цен
This commit is contained in:
Alex Lushpai 2019-05-30 14:41:26 +03:00 committed by GitHub
commit 93bacf9b7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 15 deletions

View File

@ -1,3 +1,6 @@
## v.3.3.4
* Исправлен баг с некорректной выгрузкой акционных цен для товаров с характеристиками
## v.3.3.3
* Добавлено удаление типа цены товара для неустановленных акционных цен

View File

@ -1 +1 @@
3.3.3
3.3.4

View File

@ -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;
}
/**

View File

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