[-] BO : BugFix : #PSCFV-2476 : Shop creation : adding an error message if you do not select at least the root category

This commit is contained in:
vChabot committed 2012-05-21 12:29:37 +00:00
1 parent 51f0b1f31c
commit bd1155ed21
1 file changed
+25 -20
+25 -20
View File
@@ -540,24 +540,6 @@ class AdminShopControllerCore extends AdminController
$parent_id = (int)Tools::getValue('id_parent', 1); $parent_id = (int)Tools::getValue('id_parent', 1);
$this->afterAdd($object); $this->afterAdd($object);
$this->updateAssoShop($object->id); $this->updateAssoShop($object->id);
// Save and stay on same form
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=3&update'.$this->table.'&token='.$this->token;
// Save and back to parent
if (Tools::isSubmit('submitAdd'.$this->table.'AndBackToParent'))
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$parent_id.'&conf=3&token='.$this->token;
// Default behavior (save and back)
if (empty($this->redirect_after))
$this->redirect_after = self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=3&token='.$this->token;
}
}
$this->errors = array_unique($this->errors);
if (count($this->errors) > 0)
{
$this->display = 'add';
return;
}
// datas to import // datas to import
$import_data = Tools::getValue('importData'); $import_data = Tools::getValue('importData');
@@ -571,8 +553,31 @@ class AdminShopControllerCore extends AdminController
} }
// if we import datas from another shop, we do not update the shop categories // if we import datas from another shop, we do not update the shop categories
if (!isset($import_data['category'])) if (!Category::updateFromShop(Tools::getValue('categoryBox'), $object->id))
Category::updateFromShop(Tools::getValue('categoryBox'), $object->id); $this->errors[] = $this->l('You need to select at least the root category.');
// Save and stay on same form
if (!$this->errors)
{
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=3&update'.$this->table.'&token='.$this->token;
// Save and back to parent
if (Tools::isSubmit('submitAdd'.$this->table.'AndBackToParent'))
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$parent_id.'&conf=3&token='.$this->token;
// Default behavior (save and back)
if (empty($this->redirect_after))
$this->redirect_after = self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=3&token='.$this->token;
}
}
}
$this->errors = array_unique($this->errors);
if (!empty($this->errors))
{
// if we have errors, we stay on the form instead of going back to the list
$this->display = 'edit';
return false;
}
return $object; return $object;
} }