Example #1
0
 public function load(\Doctrine\Common\Persistence\ObjectManager $manager)
 {
     $faker = \Faker\Factory::create('fr_FR');
     // generate data by accessing properties
     echo $faker->name;
     //$faker->randomElement($category)
     for ($i = 0; $i < 10; $i++) {
         $product = new Product();
         $product->setTitle($faker->text(10));
         $product->setDescription($faker->text());
         $product->setQuantity($faker->randomDigitNotNull);
         $product->setPrice($faker->randomFloat(2, 0, 1000));
         //$product->setReference($faker->randomLetter);
         //$product->setActivate($faker->numberBetween(0,1));
         $category = $this->getReference('categ' . $i);
         $product->setCategorie($category);
         $product->setMarque($manager->getRepository('TroiswaBackBundle:Marque')->find(2));
         $manager->persist($product);
         $manager->flush();
     }
 }