From 82c7cdeb4483f383115791ba33b5add7978e1c29 Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 17 Sep 2013 17:39:12 +0200 Subject: [PATCH] Working : Content : fix loop giving no elements --- core/lib/Thelia/Core/Template/Loop/Product.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index d0d8dc5b7..489587a71 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -175,14 +175,17 @@ class Product extends BaseI18nLoop if (!is_null($category) ||!is_null($categoryDefault)) { - $categories = array(); - if (!is_null($category)) { - $categories = array_merge($categories, CategoryQuery::create()->filterById($category, Criteria::IN)->find()); + $categoryIds = array(); + if (!is_array($category)) { + $category = array(); } - if (!is_null($categoryDefault)) { - $categories = array_merge($categories, CategoryQuery::create()->filterById($categoryDefault, Criteria::IN)->find()); + if (!is_array($categoryDefault)) { + $categoryDefault = array(); } + $categoryIds = array_merge($categoryIds, $category, $categoryDefault); + $categories =CategoryQuery::create()->filterById($categoryIds, Criteria::IN)->find(); + $depth = $this->getDepth(); if (null !== $depth) { @@ -549,12 +552,12 @@ class Product extends BaseI18nLoop $search->addDescendingOrderByColumn('real_lowest_price'); break; case "manual": - if(null === $category || count($category) != 1) + if(null === $categoryIds || count($categoryIds) != 1) throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); $search->orderByPosition(Criteria::ASC); break; case "manual_reverse": - if(null === $category || count($category) != 1) + if(null === $categoryIds || count($categoryIds) != 1) throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); $search->orderByPosition(Criteria::DESC); break;