Example #1
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     /** @var User $userAdmin */
     $userAdmin = $this->getReference('user-admin');
     $product1 = new Product();
     $product1->setName('Upsell message');
     $product1->setCode("{{ 'twig' }}");
     $product1->setUser($userAdmin);
     $manager->persist($product1);
     $product2 = new Product();
     $product2->setName('me');
     $product2->setCode('sadsadsa');
     $product2->setCurrency('$');
     $manager->persist($product2);
     $product3 = new Product();
     $product3->setName('Close message');
     $product3->setCode("{{ 'twig' }}");
     $product3->setUser($userAdmin);
     $manager->persist($product3);
     $product4 = new Product();
     $product4->setName('продукт');
     $product4->setPrice(1000);
     $product4->setCurrency('$');
     $product4->setUser($userAdmin);
     $manager->persist($product4);
     $this->setReference('product-4', $product4);
     $product5 = new Product();
     $product5->setName('продукт');
     $product5->setPrice(1000);
     $product5->setCurrency('$');
     $product5->setUser($userAdmin);
     $manager->persist($product5);
     $this->setReference('product-5', $product5);
     $manager->flush();
 }
Example #2
0
 private function createAndPersistProducts(Category $category)
 {
     for ($i = 1; $i <= $this->productsPerCategory; $i++) {
         $this->productsCount++;
         $product = new Product();
         $product->setCode(sprintf('code_%s_%s', $category->getId(), $i))->setTitle(sprintf('title %s %s %s', $category->getId(), $i, uniqid()))->setDescription(sprintf('product description %s', $i));
         $category->addProduct($product);
         $this->manager->persist($product);
         $this->setReference(sprintf('product_%s', $this->productsCount), $product);
     }
 }
Example #3
0
 private function generateContent(ObjectManager $manager)
 {
     $products = array(array('name' => 'Phone A8181', 'code' => 'A8181', 'price' => '180.0', 'content' => 'Nihil morati post haec militares avidi saepe turbarum adorti sunt Montium primum, qui divertebat in proximo, levi corpore senem atque morbosum, et hirsutis resticulis cruribus eius innexis divaricaturn sine spiramento ullo ad usque praetorium traxere praefecti.', 'enabled' => true), array('name' => 'Phone B8', 'code' => 'PB8', 'price' => '365.0', 'content' => 'Et olim licet otiosae sint tribus pacataeque centuriae et nulla suffragiorum certamina set Pompiliani redierit securitas temporis, per omnes tamen quotquot sunt partes terrarum, ut domina suscipitur et regina et ubique patrum reverenda cum auctoritate canities populique Romani nomen circumspectum et verecundum.', 'enabled' => true), array('name' => 'Tab Smart 18', 'code' => 'TAB-S18', 'price' => '320.0', 'content' => 'Cuius acerbitati uxor grave accesserat incentivum, germanitate Augusti turgida supra modum, quam Hannibaliano regi fratris filio antehac Constantinus iunxerat pater, Megaera quaedam mortalis.', 'enabled' => true));
     foreach ($products as $key => $product) {
         $entry = new Product();
         $entry->setName($product['name']);
         $entry->setCode($product['code']);
         $entry->setPrice($product['price']);
         $entry->setContent($product['content']);
         $entry->setEnabled($product['enabled']);
         $manager->persist($entry);
     }
 }
Example #4
0
 /**
  * @Given existen los siguientes productos:
  */
 public function createProducts(TableNode $tableNode)
 {
     $em = $this->getEntityManager();
     foreach ($tableNode->getHash() as $productHash) {
         $product = new Product();
         $product->setCode($productHash['codigo']);
         $product->setName($productHash['descripcion']);
         $product->setDescription($productHash['descripcion completa']);
         $product->setNumberConsumerUnit($productHash['numero UC']);
         $product->setChangeHistory($productHash['historial']);
         //We obtain the corresponding identifier to the trademark name
         $em = $this->getEntityManager();
         $trademark = $em->getRepository('AppBundle:Trademark')->findOneBy(array('name' => $productHash['marca']));
         $product->setTrademark($trademark);
         //We obtain the corresponding identifier to the barcode, both the CU and SU
         $em = $this->getEntityManager();
         $barcodeCU = $em->getRepository('AppBundle:Barcode')->findOneBy(array('code' => $productHash['codigo UC']));
         $product->setBarcodeCU($barcodeCU);
         $barcodeSU = $em->getRepository('AppBundle:Barcode')->findOneBy(array('code' => $productHash['codigo UV']));
         $product->setBarcodeSU($barcodeSU);
         $em->persist($product);
     }
     $em->flush();
 }