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(); }
/** * Load data fixtures with the passed EntityManager * * @param \Doctrine\Common\Persistence\ObjectManager $manager * @internal param $ |\Doctrine\Common\Persistence\ObjectManager $manager */ public function load(ObjectManager $manager) { $shorts = new \AppBundle\Entity\Product(); $shorts->setDescription("shorts that are sweet"); $shorts->setName("Nike Shorts"); $shorts->setSlug("shortsSlug"); $manager->persist($shorts); $shirt = new \AppBundle\Entity\Product(); $shirt->setDescription("shirt that are sweet"); $shirt->setName("Nike shirt"); $shirt->setSlug("shirtSlug"); $manager->persist($shirt); $pants = new \AppBundle\Entity\Product(); $pants->setDescription("pants that are sweet"); $pants->setName("Nike pants"); $pants->setSlug("pantsSlug"); $manager->persist($pants); $manager->flush(); }