示例#1
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     foreach ($this->fixtureFiles as $file) {
         if (file_exists($file)) {
             $contents = file_get_contents($file);
             $XML = simplexml_load_string($contents);
             foreach ($XML->database->table as $table) {
                 $product = new Product();
                 $product->setLocale($table->column[1]);
                 $product->setName($table->column[2]);
                 $product->setSku($table->column[3]);
                 $product->setPrice((double) $table->column[4]);
                 $product->setQty((int) $table->column[11]);
                 $product->setDescriptionShort($table->column[14]);
                 $product->setDescription($table->column[15]);
                 $product->setStatus((int) $table->column[16]);
                 $product->setHidden((int) $table->column[17]);
                 $product->setCommentStatus((int) $table->column[18]);
                 $product->setMetaUrl($table->column[19]);
                 $categories = explode(",", $table->column[20]);
                 foreach ($categories as $c) {
                     $category = $this->getReference('product_category_' . $c);
                     $product->addCategory($category);
                 }
                 $manager->persist($product);
                 $manager->flush();
                 $this->addReference('product_' . $table->column[0], $product);
                 $this->setProductImage($manager, $product);
             }
         }
     }
 }
示例#2
0
 /**
  * newProduct
  *
  * @return Product $product
  */
 public function newProduct()
 {
     $product = new Product();
     $product->setLocale('en');
     $product->setName($this->faker->sentence());
     $product->setSku($this->faker->randomDigit);
     $product->setPrice($this->faker->randomDigit);
     $product->setQty($this->faker->randomDigit);
     $product->setContentShort($this->faker->sentence());
     $product->setContent($this->faker->text());
     $product->setStatus(true);
     $product->setHidden(false);
     $product->setCommentStatus(false);
     $product->setMetaUrl($this->faker->numberBetween(100000000, 9999999999));
     $this->em->persist($product);
     $this->em->flush();
     return $product;
 }
示例#3
0
 /**
  * newProduct
  *
  * @return Product $product
  */
 public function newProduct()
 {
     $user = $this->em->getRepository('Aisel\\UserBundle\\Entity\\User')->findOneBy(['email' => '*****@*****.**']);
     $product = new Product();
     $product->setUser($user);
     $product->setLocale('en');
     $product->setName($this->faker->sentence());
     $product->setSku($this->faker->randomDigit);
     $product->setPrice($this->faker->randomDigit);
     $product->setQty($this->faker->randomDigit);
     $product->setContentShort($this->faker->sentence());
     $product->setContent($this->faker->text());
     $product->setStatus(true);
     $product->setHidden(false);
     $product->setCommentStatus(false);
     $product->setMetaUrl($this->faker->numberBetween(100000000, 9999999999));
     $this->em->persist($product);
     $this->em->flush();
     return $product;
 }
示例#4
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     // Delete all files and directories
     $this->cleanMediaDir();
     foreach ($this->fixtureFiles as $file) {
         if (file_exists($file)) {
             $contents = file_get_contents($file);
             $XML = simplexml_load_string($contents);
             foreach ($XML->database->table as $table) {
                 $user = $this->getReference('user_' . $table->column[1]);
                 $product = new Product();
                 $product->setUser($user);
                 $product->setLocale($table->column[2]);
                 $product->setName($table->column[3]);
                 $product->setSku($table->column[4]);
                 $product->setPrice((int) $table->column[5]);
                 $product->setQty((int) $table->column[12]);
                 $product->setContentShort($table->column[15]);
                 $product->setContent($table->column[16]);
                 $product->setStatus((int) $table->column[17]);
                 $product->setHidden((int) $table->column[18]);
                 $product->setCommentStatus((int) $table->column[19]);
                 $product->setMetaUrl($table->column[20]);
                 $nodes = explode(",", $table->column[21]);
                 foreach ($nodes as $c) {
                     $node = $this->getReference('product_node_' . $c);
                     $product->addNode($node);
                 }
                 $manager->persist($product);
                 $manager->flush();
                 $this->addReference('product_' . $table->column[0], $product);
                 $images = $this->setProductImage($manager, $product);
                 $product->setMedias($images);
                 $manager->persist($product);
                 $manager->flush();
             }
         }
     }
 }