/** * {@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); } } } }