My project is with Webservices add categories and when I refresh the file of categories it creates the same categories I had before.
foreach ($XMLRSString->Families->Family as $family)
{
$categories = $family->Code;
$exists = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('select id_category from ps_category where id_category = "'.$categories['id_category'].'"');
$category = new Category((int)$categories);
$category->id= (int)$categories;
$category->id_category_default=(int)$family->Code;
$category->force_id = true;
$category->is_root_category = false;
$category->name = array((int)Configuration::get('PS_LANG_DEFAULT') => $family->Designation);
$category->link_rewrite = array((int)Configuration::get('PS_LANG_DEFAULT') => $family->Code);
$category->id_parent = Configuration::get('PS_HOME_CATEGORY');
if($exists){
$category->add();
echo "created ".$family->Code."<br>";
}
else{
$category->save();
echo "already exists ".$family->Code."<br>";
}
}
It doesn't appear any error but it doesn't show up on PrestaShop categories