/** * {@inheritDoc} */ public function load(ObjectManager $manager) { for ($x = 0; $x < 50; $x++) { $feature1 = new Feature(); $feature1->setName("Name 1"); $feature2 = new Feature(); $feature2->setName("Name 2"); $product = new Product(); $product->setDescription("Description " . $x)->setName("Name " . $x)->setPrice($x)->setFeatures(array($feature1, $feature2)); $manager->persist($product); } $manager->flush(); }
public function load(ObjectManager $manager) { for ($i = 0; $i < 40; $i++) { $product = new Product(); $product->setName('Name Product ' . $i); $featureA = new Feature(); $featureA->setName('Description'); $featureA->setDescription("This is a feature's description"); $featureA->setProduct($product); $manager->persist($featureA); $product->addFeature($featureA); $featureB = new Feature(); $featureB->setName('Warranty'); $featureB->setDescription("This is a warranty's description"); $featureB->setProduct($product); $manager->persist($featureB); $product->addFeature($featureB); $manager->persist($product); } $manager->flush(); }