public function createDummyContents($option_value, $design, $category) { $option = new Application_Model_Option(); $option->find($option_value->getOptionId()); $dummy_content_xml = $this->_getDummyXml($design, $category); if ($option->getCode() == "catalog") { foreach ($dummy_content_xml->catalog->children() as $categories) { $this->unsData(); //check si la category existe sur cette app $category_data = array("name" => $categories->name, "value_id" => $option_value->getId()); $category_id = $this->find($category_data)->getCategoryId(); if (!$category_id) { $this->setName((string) $categories->name)->setValueId($option_value->getId())->save(); $category_id = $this->getId(); } foreach ($categories->products->children() as $product) { $product_model = new Catalog_Model_Product(); if ($product->attributes()->subcategory) { $sub_category_model = new Catalog_Model_Category(); //check si la sous category existe sur cette app $subcategory_data = array("name" => $product->attributes()->subcategory, "value_id" => $option_value->getId()); $sub_category_model->find($subcategory_data); if (!$sub_category_model->getCategoryId()) { $sub_category_model->setName($product->attributes()->subcategory)->setValueId($option_value->getId())->setParentId($category_id)->save(); $product_model->setCategoryId($sub_category_model->getId()); } else { $sub_category_model->setParentId($category_id)->save(); $product_model->setCategoryId($sub_category_model->getId()); } } else { $product_model->setCategoryId($category_id); } foreach ($product->content->children() as $key => $value) { $product_model->addData((string) $key, (string) $value); } if ($product->formats) { $format_option = array(); foreach ($product->formats->children() as $format) { foreach ($format as $key => $val) { $format_option[$format->getName()][(string) $key] = (string) $val; } } $product_model->setOption($format_option); } $product_model->setValueId($option_value->getId())->save(); } } } }