From fb0c45bfd06f4e3d8d083af7a9012029a016ea75 Mon Sep 17 00:00:00 2001 From: opheugene Date: Thu, 12 Nov 2020 13:57:54 +0300 Subject: [PATCH] Fixed root-category relation with home-category Co-authored-by: Eugene Polozov --- retailcrm/lib/RetailcrmCatalog.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/retailcrm/lib/RetailcrmCatalog.php b/retailcrm/lib/RetailcrmCatalog.php index f812fb6..eb18ca6 100644 --- a/retailcrm/lib/RetailcrmCatalog.php +++ b/retailcrm/lib/RetailcrmCatalog.php @@ -88,7 +88,7 @@ class RetailcrmCatalog $categoriesIds[] = $categoryId; $categories[] = array( 'id' => $categoryId, - 'parentId' => self::getParentCategoryId($category['id_parent']), + 'parentId' => self::getParentCategoryId($categoryId, $category['id_parent']), 'name' => $category['name'], 'picture' => $picture ? $protocol . $picture : '' ); @@ -173,7 +173,7 @@ class RetailcrmCatalog $width = round($product['width'], 3); $height = round($product['height'], 3); $depth = round($product['depth'], 3); - + if (!empty($width) && !empty($height)) { $dimensions = implode('/', array($width, $height, $depth)); } else { @@ -231,7 +231,7 @@ class RetailcrmCatalog if ($offerCombination->wholesale_price > 0) { $offerPurchasePrice = round($offerCombination->wholesale_price, 2); } else { - $offerPurchasePrice = $purchasePrice; + $offerPurchasePrice = $purchasePrice; } if (!empty($offerCombination->reference)) { @@ -295,7 +295,7 @@ class RetailcrmCatalog 'vendor' => $vendor, 'article' => $article, 'weight' => $weight, - 'dimensions' => $dimensions + 'dimensions' => $dimensions ); $items[] = $item; @@ -336,16 +336,21 @@ class RetailcrmCatalog /** * Returns active parent category * + * @param int $categoryId * @param int $parentId * * @return null */ - private static function getParentCategoryId($parentId) + private static function getParentCategoryId($categoryId, $parentId) { $home = Configuration::get('PS_HOME_CATEGORY'); if (empty($parentId)) { - return $home; + return null; + } + + if ($categoryId == $home) { + return null; } if ($parentId == $home) {