diff --git a/classes/Attribute.php b/classes/Attribute.php index 1c9b6211b..45ff59993 100644 --- a/classes/Attribute.php +++ b/classes/Attribute.php @@ -255,12 +255,16 @@ class AttributeCore extends ObjectModel */ public function updatePosition($way, $position) { - if (!$res = Db::getInstance()->executeS(' + if (!$id_attribute_group = (int)Tools::getValue('id_attribute_group')) + $id_attribute_group = (int)$this->id_attribute_group; + + $sql = ' SELECT a.`id_attribute`, a.`position`, a.`id_attribute_group` FROM `'._DB_PREFIX_.'attribute` a - WHERE a.`id_attribute_group` = '.(int)Tools::getValue('id_attribute_group', 1).' - ORDER BY a.`position` ASC' - )) + WHERE a.`id_attribute_group` = '.(int)$id_attribute_group.' + ORDER BY a.`position` ASC'; + + if (!$res = Db::getInstance()->executeS($sql)) return false; foreach ($res as $attribute) diff --git a/controllers/admin/AdminAttributesGroupsController.php b/controllers/admin/AdminAttributesGroupsController.php index 1703cc750..e32c472f3 100644 --- a/controllers/admin/AdminAttributesGroupsController.php +++ b/controllers/admin/AdminAttributesGroupsController.php @@ -573,14 +573,17 @@ class AdminAttributesGroupsControllerCore extends AdminController if (!Combination::isFeatureActive()) return; - // If it's an attribute, load object Attribute() - if (Tools::getValue('updateattribute') || Tools::isSubmit('deleteattribute') || Tools::isSubmit('submitAddattribute')) + if (!Tools::getValue($this->identifier) && Tools::getValue('id_attribute') && !Tools::getValue('attributeOrderby')) { // Override var of Controller $this->table = 'attribute'; $this->className = 'Attribute'; $this->identifier = 'id_attribute'; + } + // If it's an attribute, load object Attribute() + if (Tools::getValue('updateattribute') || Tools::isSubmit('deleteattribute') || Tools::isSubmit('submitAddattribute')) + { if ($this->tabAccess['edit'] !== '1') $this->errors[] = Tools::displayError('You do not have permission to edit here.'); else if (!$object = new Attribute((int)Tools::getValue($this->identifier))) diff --git a/js/admin-dnd.js b/js/admin-dnd.js index be810c293..d93df4416 100644 --- a/js/admin-dnd.js +++ b/js/admin-dnd.js @@ -148,9 +148,9 @@ function initTableDnD(table) $(this).attr('id', $(this).attr('id').replace(reg, '_' + i)); // Update link position // Up links - $(this).children('td.dragHandle a:odd').attr('href', $(this).children('td.dragHandle a:odd').attr('href').replace(up_reg, 'position='+ (i - 1) +'&')); + $(this).find('td.dragHandle a:odd').attr('href', $(this).find('td.dragHandle a:odd').attr('href').replace(up_reg, 'position='+ (i - 1) +'&')); // Down links - $(this).children('td.dragHandle a:even').attr('href', $(this).children('td.dragHandle a:even').attr('href').replace(up_reg, 'position='+ (i + 1) +'&')); + $(this).find('td.dragHandle a:even').attr('href', $(this).find('td.dragHandle a:even').attr('href').replace(up_reg, 'position='+ (i + 1) +'&')); }); }