beginTransaction(); $currency = \Thelia\Model\CurrencyQuery::create()->filterByCode('EUR')->findOne(); try { $category = Thelia\Model\CategoryQuery::create() ->find(); $category->delete(); $product = Thelia\Model\ProductQuery::create() ->find(); $product->delete(); $customer = Thelia\Model\CustomerQuery::create() ->find(); $customer->delete(); $customer = new Thelia\Model\Customer(); $customer->createOrUpdate( 1, "thelia", "thelia", "5 rue rochon", "", "", "0102030405", "0601020304", "63000", "clermont-ferrand", 64, "test@thelia.net", "azerty" ); $folder = Thelia\Model\FolderQuery::create() ->find(); $folder->delete(); $content = Thelia\Model\ContentQuery::create() ->find(); $content->delete(); //first category $sweet = new Thelia\Model\Category(); $sweet->setParent(0); $sweet->setVisible(1); $sweet->setPosition(1); $sweet->setDescription($faker->text(255)); $sweet->setTitle($faker->text(20)); $sweet->save(); //second category $jeans = new Thelia\Model\Category(); $jeans->setParent(0); $jeans->setVisible(1); $jeans->setPosition(2); $jeans->setDescription($faker->text(255)); $jeans->setTitle($faker->text(20)); $jeans->save(); //third category $other = new Thelia\Model\Category(); $other->setParent($jeans->getId()); $other->setVisible(1); $other->setPosition(3); $other->setDescription($faker->text(255)); $other->setTitle($faker->text(20)); $other->save(); for ($i=1; $i <= 5; $i++) { $product = new \Thelia\Model\Product(); $product->addCategory($sweet); $product->setTitle($faker->text(20)); $product->setDescription($faker->text(250)); /* $product->setQuantity($faker->randomNumber(1,50)); $product->setPrice($faker->randomFloat(2, 20, 2500));*/ $product->setVisible(1); $product->setPosition($i); $product->setRef($faker->text(255)); $product->save(); $stock = new \Thelia\Model\ProductSaleElements(); $stock->setProduct($product); $stock->setQuantity($faker->randomNumber(1,50)); $stock->setPromo($faker->randomNumber(0,1)); $stock->save(); $productPrice = new \Thelia\Model\ProductPrice(); $productPrice->setProductSaleElements($stock); $productPrice->setCurrency($currency); $productPrice->setPrice($faker->randomFloat(2, 20, 2500)); $productPrice->save(); } for ($i=1; $i <= 5; $i++) { $product = new \Thelia\Model\Product(); $product->addCategory($jeans); $product->setTitle($faker->text(20)); $product->setDescription($faker->text(250)); /* $product->setQuantity($faker->randomNumber(1,50)); $product->setPrice($faker->randomFloat(2, 20, 2500));*/ $product->setVisible(1); $product->setPosition($i); $product->setRef($faker->text(255)); $product->save(); $stock = new \Thelia\Model\ProductSaleElements(); $stock->setProduct($product); $stock->setQuantity($faker->randomNumber(1,50)); $stock->setPromo($faker->randomNumber(0,1)); $stock->save(); $productPrice = new \Thelia\Model\ProductPrice(); $productPrice->setProductSaleElements($stock); $productPrice->setCurrency($currency); $productPrice->setPrice($faker->randomFloat(2, 20, 2500)); $productPrice->save(); } //folders and contents 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($j=0; $jsetParent($folder->getId()); $subfolder->setVisible(rand(1, 10)>7 ? 0 : 1); $subfolder->setPosition($j); $subfolder->setTitle($faker->text(20)); $subfolder->setDescription($faker->text(255)); $subfolder->save(); for($k=0; $kaddFolder($subfolder); $content->setVisible(rand(1, 10)>7 ? 0 : 1); $content->setPosition($k); $content->setTitle($faker->text(20)); $content->setDescription($faker->text(255)); $content->save(); } } } //features and features_av for($i=0; $i<4; $i++) { $feature = new Thelia\Model\Feature(); $feature->setVisible(rand(1, 10)>7 ? 0 : 1); $feature->setPosition($i); $feature->setTitle($faker->text(20)); $feature->setDescription($faker->text(50)); $feature->save(); for($j=0; $jsetFeature($feature); $featureAv->setPosition($j); $featureAv->setTitle($faker->text(20)); $featureAv->setDescription($faker->text(255)); $featureAv->save(); } } $con->commit(); } catch (Exception $e) { echo "error : ".$e->getMessage()."\n"; $con->rollBack(); }