diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index f6ab423ab..daa07341b 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -73,6 +73,7 @@ class Product extends BaseI18nLoop ) ), Argument::createIntListTypeArgument('category'), + Argument::createIntListTypeArgument('category_default'), Argument::createBooleanTypeArgument('new'), Argument::createBooleanTypeArgument('promo'), Argument::createFloatTypeArgument('min_price'), @@ -170,9 +171,16 @@ class Product extends BaseI18nLoop } $category = $this->getCategory(); + $categoryDefault = $this->getCategoryDefault(); - if (!is_null($category)) { - $categories = CategoryQuery::create()->filterById($category, Criteria::IN)->find(); + if (!is_null($category) ||!is_null($categoryDefault)) { + + if (!is_null($category)) { + $categories = CategoryQuery::create()->filterById($category, Criteria::IN)->find(); + } + if (!is_null($categoryDefault)) { + $categories = CategoryQuery::create()->filterById($categoryDefault, Criteria::IN)->find(); + } $depth = $this->getDepth(); diff --git a/install/faker.php b/install/faker.php index e9b654c6b..0b0ea38e2 100755 --- a/install/faker.php +++ b/install/faker.php @@ -453,11 +453,16 @@ try { $con->rollBack(); } -function createProduct($faker, $category, $position, $template, &$productIdList) +function createProduct($faker, Thelia\Model\Category $category, $position, $template, &$productIdList) { $product = new Thelia\Model\Product(); $product->setRef($category->getId() . '_' . $position . '_' . $faker->randomNumber(8)); $product->addCategory($category); + $productCategories = $product->getProductCategories(); + $productCategories[0]->setDefaultCategory(true); + $collection = new \Propel\Runtime\Collection\Collection(); + $collection->append($productCategories[0]->setDefaultCategory(true)); + $product->setProductCategories($collection); $product->setVisible(rand(1, 10)>7 ? 0 : 1); $product->setPosition($position); $product->setTaxRuleId(1); diff --git a/reset_install.sh b/reset_install.sh index 380a80a5f..348927a54 100755 --- a/reset_install.sh +++ b/reset_install.sh @@ -18,7 +18,7 @@ echo -e "\n\e[01;34m[INFO] Building Models file\e[00m\n" echo -e "\n\e[01;34m[INFO] Building SQL CREATE file\e[00m\n" ../../bin/propel sql:build -v --output-dir=../../install/ -echo -e "\n\e[01;34m[INFO] Reloaded Thelia2 database\e[00m\n" +echo -e "\n\e[01;34m[INFO] Reloading Thelia2 database\e[00m\n" cd ../.. rm install/sqldb.map php Thelia thelia:dev:reloadDB