change faker

This commit is contained in:
Etienne Roudeix
2013-08-02 15:35:06 +02:00
parent 8874404e4d
commit aac1533e65
2 changed files with 36 additions and 24 deletions

View File

@@ -38,27 +38,9 @@ use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
/** /**
*
* Folder loop, all params available :
*
* - id : can be an id (eq : 3) or a "string list" (eg: 3, 4, 5)
* - parent : categories having this parent id
* - current : current id is used if you are on a folder page
* - not_empty : if value is 1, folder and subcategories must have at least 1 product
* - visible : default 1, if you want folder not visible put 0
* - order : all value available : 'alpha', 'alpha_reverse', 'manual' (default), 'manual-reverse', 'random'
* - exclude : all folder id you want to exclude (as for id, an integer or a "string list" can be used)
*
* example :
*
* <THELIA_cat type="folder" parent="3" limit="4">
* #TITLE : #ID
* </THELIA_cat>
*
*
* Class Folder * Class Folder
*
* @package Thelia\Core\Template\Loop * @package Thelia\Core\Template\Loop
* @author Manuel Raynaud <mraynaud@openstudio.fr>
* @author Etienne Roudeix <eroudeix@openstudio.fr> * @author Etienne Roudeix <eroudeix@openstudio.fr>
*/ */
class Folder extends BaseLoop class Folder extends BaseLoop

View File

@@ -20,13 +20,21 @@ try {
->find(); ->find();
$product->delete(); $product->delete();
$folder = Thelia\Model\FolderQuery::create()
->find();
$folder->delete();
$content = Thelia\Model\ContentQuery::create()
->find();
$content->delete();
//first category //first category
$sweet = new Thelia\Model\Category(); $sweet = new Thelia\Model\Category();
$sweet->setParent(0); $sweet->setParent(0);
$sweet->setVisible(1); $sweet->setVisible(1);
$sweet->setPosition(1); $sweet->setPosition(1);
$sweet->setDescription($faker->text(255)); $sweet->setDescription($faker->text(255));
$sweet->setTitle($faker->bs); $sweet->setTitle($faker->text(20));
$sweet->save(); $sweet->save();
@@ -36,7 +44,7 @@ try {
$jeans->setVisible(1); $jeans->setVisible(1);
$jeans->setPosition(2); $jeans->setPosition(2);
$jeans->setDescription($faker->text(255)); $jeans->setDescription($faker->text(255));
$jeans->setTitle($faker->bs); $jeans->setTitle($faker->text(20));
$jeans->save(); $jeans->save();
@@ -46,14 +54,14 @@ try {
$other->setVisible(1); $other->setVisible(1);
$other->setPosition(3); $other->setPosition(3);
$other->setDescription($faker->text(255)); $other->setDescription($faker->text(255));
$other->setTitle($faker->bs); $other->setTitle($faker->text(20));
$other->save(); $other->save();
for ($i=1; $i <= 5; $i++) { for ($i=1; $i <= 5; $i++) {
$product = new \Thelia\Model\Product(); $product = new \Thelia\Model\Product();
$product->addCategory($sweet); $product->addCategory($sweet);
$product->setTitle($faker->bs); $product->setTitle($faker->text(20));
$product->setDescription($faker->text(250)); $product->setDescription($faker->text(250));
/* $product->setQuantity($faker->randomNumber(1,50)); /* $product->setQuantity($faker->randomNumber(1,50));
$product->setPrice($faker->randomFloat(2, 20, 2500));*/ $product->setPrice($faker->randomFloat(2, 20, 2500));*/
@@ -79,7 +87,7 @@ try {
for ($i=1; $i <= 5; $i++) { for ($i=1; $i <= 5; $i++) {
$product = new \Thelia\Model\Product(); $product = new \Thelia\Model\Product();
$product->addCategory($jeans); $product->addCategory($jeans);
$product->setTitle($faker->bs); $product->setTitle($faker->text(20));
$product->setDescription($faker->text(250)); $product->setDescription($faker->text(250));
/* $product->setQuantity($faker->randomNumber(1,50)); /* $product->setQuantity($faker->randomNumber(1,50));
$product->setPrice($faker->randomFloat(2, 20, 2500));*/ $product->setPrice($faker->randomFloat(2, 20, 2500));*/
@@ -102,6 +110,28 @@ try {
} }
//folders
for($i=0; $i<4; $i++) {
$folder = new Thelia\Model\Folder();
$folder->setParent(0);
$folder->setVisible(rand(1, 10)>7 ? 0 : 1);
$folder->setPosition($i);
$folder->setTitle($faker->text(20));
$folder->setDescription($faker->text(255));
$folder->save();
for($i=0; $i<rand(0, 4); $i++) {
$subfolder = new Thelia\Model\Folder();
$subfolder->setParent($folder->getId());
$subfolder->setVisible(rand(1, 10)>7 ? 0 : 1);
$subfolder->setPosition($i);
$subfolder->setTitle($faker->text(20));
$subfolder->setDescription($faker->text(255));
$subfolder->save();
}
}
$con->commit(); $con->commit();
} catch (Exception $e) { } catch (Exception $e) {