Working : Content : fix loop giving no elements

This commit is contained in:
gmorel
2013-09-17 17:39:12 +02:00
parent df80d39954
commit 82c7cdeb44

View File

@@ -175,14 +175,17 @@ class Product extends BaseI18nLoop
if (!is_null($category) ||!is_null($categoryDefault)) { if (!is_null($category) ||!is_null($categoryDefault)) {
$categories = array(); $categoryIds = array();
if (!is_null($category)) { if (!is_array($category)) {
$categories = array_merge($categories, CategoryQuery::create()->filterById($category, Criteria::IN)->find()); $category = array();
} }
if (!is_null($categoryDefault)) { if (!is_array($categoryDefault)) {
$categories = array_merge($categories, CategoryQuery::create()->filterById($categoryDefault, Criteria::IN)->find()); $categoryDefault = array();
} }
$categoryIds = array_merge($categoryIds, $category, $categoryDefault);
$categories =CategoryQuery::create()->filterById($categoryIds, Criteria::IN)->find();
$depth = $this->getDepth(); $depth = $this->getDepth();
if (null !== $depth) { if (null !== $depth) {
@@ -549,12 +552,12 @@ class Product extends BaseI18nLoop
$search->addDescendingOrderByColumn('real_lowest_price'); $search->addDescendingOrderByColumn('real_lowest_price');
break; break;
case "manual": 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'); throw new \InvalidArgumentException('Manual order cannot be set without single category argument');
$search->orderByPosition(Criteria::ASC); $search->orderByPosition(Criteria::ASC);
break; break;
case "manual_reverse": 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'); throw new \InvalidArgumentException('Manual order cannot be set without single category argument');
$search->orderByPosition(Criteria::DESC); $search->orderByPosition(Criteria::DESC);
break; break;