From d56065a1af53560feba3dbd3cbe1b78af349d172 Mon Sep 17 00:00:00 2001 From: Frosin Date: Wed, 21 Aug 2019 15:02:23 +0300 Subject: [PATCH] fixed offer'ss article, prices display in catalog --- retailcrm/lib/RetailcrmCatalog.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/retailcrm/lib/RetailcrmCatalog.php b/retailcrm/lib/RetailcrmCatalog.php index cca45b0..f1cfd49 100644 --- a/retailcrm/lib/RetailcrmCatalog.php +++ b/retailcrm/lib/RetailcrmCatalog.php @@ -148,9 +148,23 @@ class RetailcrmCatalog $quantity = (int) StockAvailable::getQuantityAvailableByProduct($product['id_product'], $offer['id_product_attribute']); } - $offerPrice = Combination::getPrice($offer['id_product_attribute']); + $offerCombination = new Combination($offer['id_product_attribute']); + + $offerPrice = $offerCombination->price + $price; $offerPrice = $offerPrice > 0 ? $offerPrice : $price; + if ($offerCombination->wholesale_price > 0) { + $offerPurchasePrice = round($offerCombination->wholesale_price, 2); + } else { + $offerPurchasePrice = $purchasePrice; + } + + if (!empty($offerCombination->reference)) { + $offerArticle = htmlspecialchars($offerCombination->reference); + } else { + $offerArticle = $article; + } + $item = array( 'id' => $product['id_product'] . '#' . $offer['id_product_attribute'], 'productId' => $product['id_product'], @@ -161,10 +175,10 @@ class RetailcrmCatalog 'picture' => $pictures, 'url' => $url, 'quantity' => $quantity > 0 ? $quantity : 0, - 'purchasePrice' => $purchasePrice, + 'purchasePrice' => $offerPurchasePrice, 'price' => round($offerPrice, 2), 'vendor' => $vendor, - 'article' => $article, + 'article' => $offerArticle, 'weight' => $weight, 'dimensions' => $dimensions );