Example #1
0
 public function load(\Doctrine\Common\Persistence\ObjectManager $manager)
 {
     $faker = \Faker\Factory::create();
     for ($i = 1; $i <= 1000; $i++) {
         $product = new \AppBundle\Entity\Product();
         $product->setName(ucfirst($faker->sentence(3)));
         $product->setDescription($faker->text);
         $product->setPrice($faker->randomFloat());
         $product->setAmount($faker->numberBetween(0, 20));
         $product->setCategory($this->getReference('category-' . $faker->numberBetween(1, 100)));
         $manager->persist($product);
     }
     $manager->flush();
 }