Ejemplo n.º 1
0
 public function load(ObjectManager $manager)
 {
     for ($i = 0; $i < 10; $i++) {
         $product = new Product();
         $product->setTitle('Demo pica ' . ($i + 1));
         $product->setImage('http://www.cili.lt/wp-content/uploads/2015/09/STUDENTU.jpg');
         $product->setDeleted(0);
         $product->setPrice(5 + $i);
         $product->setCurrency('EUR');
         $product->setDescription('Virtas kiaulienos kumpis, dešrelės, mocarela, sūris, pomidorų padažas, aliejaus ir česnako padažas, raudonėliai.');
         $product->setSupplier($this->getReference('supplier'));
         $this->addReference("product{$i}", $product);
         $manager->persist($product);
         $manager->flush();
     }
 }
 /**
  * @param EntityManagerInterface $entityManager
  * @param $data
  */
 private function create(EntityManagerInterface $entityManager, $data)
 {
     $product = new Product();
     $product->setSupplier($data['supplier']);
     $product->setTitle($data['title']);
     $product->setPrice($data['price']);
     $product->setCurrency($data['currency']);
     $product->setImage($data['imageUrl']);
     $product->setDescription($data['description']);
     $entityManager->persist($product);
 }