From 17eda017609c0e77b4888a0c4b1092e790ca70d5 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Mon, 5 Sep 2016 11:57:43 +0200 Subject: [PATCH] modif for children cat --- modules/categoryimg/categoryimg.php | 6 +++++- override/controllers/ProductController.php | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/categoryimg/categoryimg.php b/modules/categoryimg/categoryimg.php index d8a06ac0..8395907c 100755 --- a/modules/categoryimg/categoryimg.php +++ b/modules/categoryimg/categoryimg.php @@ -42,8 +42,12 @@ class CategoryImg extends Module { } } } - if (file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$params['id_category'].'_thumb_vp.jpg') && $params['id_category'] != $category->id) { + if ($category && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$params['id_category'].'_thumb_vp.jpg') && $params['id_category'] != $category->id) { $id_category_thumb = $params['id_category']; + } elseif ($category && $id_parent && file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_parent.'_thumb_vp.jpg') && $id_parent!= $category->id) { + $id_category_thumb = $id_parent; + } elseif ($category && $parent_bis && file_exists(_PS_ROOT_DIR_.'/img/c/'.$parent_bis.'_thumb_vp.jpg') && $parent_bis!= $category->id) { + $id_category_thumb = $parent_bis; } else { $id_category_thumb = $category->id; } diff --git a/override/controllers/ProductController.php b/override/controllers/ProductController.php index 4d3a3bd6..9b53f8bc 100755 --- a/override/controllers/ProductController.php +++ b/override/controllers/ProductController.php @@ -7,7 +7,7 @@ class ProductController extends ProductControllerCore { $id_category = $this->product->id_category_default; $sale = Sale::getSaleFromCategory($id_category); - /* Find out the good Category for thumb*/ + /* Finding out the right Category for thumb*/ $found_category = false; if (isset($_SERVER['HTTP_REFERER']) AND preg_match('!^(.*)\/([0-9]+)\-(.*[^\.])|(.*)id_category=([0-9]+)(.*)$!', $_SERVER['HTTP_REFERER'], $regs) AND !strstr($_SERVER['HTTP_REFERER'], '.html')) { @@ -23,11 +23,19 @@ class ProductController extends ProductControllerCore { } } + $parent_category = ($found_category)?Category::getIdParent((int)$found_category):Category::getIdParent((int)$id_category); + if ($found_category && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$found_category.'_thumb_vp.jpg') && $found_category != $sale->id_category) { + // cat thumb $id_category_thumb = $found_category; + } elseif ($parent_category && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$parent_category.'_thumb_vp.jpg') && $parent_category != $sale->id_category) { + // parent cat thumb + $id_category_thumb = $parent_category; } elseif (file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$id_category.'_thumb_vp.jpg') && $id_category != $sale->id_category) { + // default cat thumb $id_category_thumb = $id_category; } else { + // sale cat thumb $id_category_thumb = $sale->id_category; }