[*] Classes: calcul position in class when an attribute, an image or a scene is added

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9638 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-10-25 15:17:26 +00:00
parent 962c48728b
commit c7a984c927
4 changed files with 36 additions and 21 deletions
+4 -1
View File
@@ -124,6 +124,9 @@ class AttributeCore extends ObjectModel
public function add($autodate = true, $null_values = false)
{
if ($this->position <= 0)
$this->position = Attribute::getHigherPosition($this->id_attribute_group) + 1;
$return = parent::add($autodate, $null_values);
if ($return)
Module::hookExec('afterSaveAttribute', array('id_attribute' => $this->id));
@@ -339,7 +342,7 @@ class AttributeCore extends ObjectModel
FROM `'._DB_PREFIX_.'attribute`
WHERE id_attribute_group = '.(int)$id_attribute_group;
$position = DB::getInstance()->getValue($sql);
return ($position !== false) ? $position : -1;
return (is_numeric($position)) ? $position : -1;
}
}