From 1b836a3920cc3694e69e68c0dde7963630d413c3 Mon Sep 17 00:00:00 2001 From: vChabot Date: Wed, 21 Sep 2011 09:03:53 +0000 Subject: [PATCH] // add add_attribute_position.php file to update attribute position git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8678 b9a71923-0436-4b27-9f14-aed3839534dd --- install-dev/php/add_attribute_position.php | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 install-dev/php/add_attribute_position.php diff --git a/install-dev/php/add_attribute_position.php b/install-dev/php/add_attribute_position.php new file mode 100755 index 000000000..f23e439df --- /dev/null +++ b/install-dev/php/add_attribute_position.php @@ -0,0 +1,51 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 6844 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +function add_attribute_position() +{ + $groups = Db::getInstance()->ExecuteS(' + SELECT `id_attribute_group` + FROM `'._DB_PREFIX_.'attribute`'); + if (sizeof($groups) && is_array($groups)) + foreach ($groups as $group) + { + $attributes = Db::getInstance()->ExecuteS(' + SELECT * + FROM `'._DB_PREFIX_.'attribute` + WHERE `id_attribute_group` = '. (int)($group['id_attribute_group'])); + $i = 0; + if (sizeof($attributes) && is_array($attributes)) + foreach ($attributes as $attribute) + { + Db::getInstance()->Execute(' + UPDATE `'._DB_PREFIX_.'attribute` + SET `position` = '.$i++.' + WHERE `id_attribute` = '.(int)$attribute['id_attribute'].' + AND `id_attribute_group` = '.(int)$attribute['id_attribute_group']); + } + } +} \ No newline at end of file