//Update an existing product or Create a new one $resources->reference = $product_xml->ItemNumber; $resources->price = floatval($product_xml->BasePrice); $resources->wholesale_price = floatval($product_xml->LowestPrice); $category = CategoryCore::searchByName(1, $product_xml->Category); if(!isset($category[0]['id_category'])){ $category_id = add_new_category($product_xml->Category,34); } else{ $category_id = $category[0]['id_category']; } if($product_xml->Category != $product_xml->SubCategory){ $sub_category = CategoryCore::searchByName(1, $product_xml->SubCategory); if(!isset($sub_category[0]['id_category'])){ $sub_category_id = add_new_category($product_xml->SubCategory,$category_id); } else{ $sub_category_id = $sub_category[0]['id_category']; } $resources->associations->categories->addChild('categories')->addChild('id',intval($sub_category_id)); $resources->id_category_default = intval($sub_category_id); } else{ $resources->id_category_default = intval($category_id); } $resources->associations->categories->addChild('categories')->addChild('id',intval($category_id));