Working : Fixture : Product add default category
This commit is contained in:
@@ -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) ||!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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user