* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6626 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ /** * Removes duplicates from table category_group caused by a bug in category importing in PS < 1.4.2 */ function remove_duplicate_category_groups() { $result = Db::getInstance()->ExecuteS(' SELECT `id_category`, `id_group`, COUNT(*) as `count` FROM `'._DB_PREFIX_.'category_group` GROUP BY `id_category`, `id_group` ORDER BY `count` DESC'); foreach($result as $row) { if ((int)$row['count'] > 1) { $limit = (int)$row['count'] - 1; $result = Db::getInstance()->Execute(' DELETE FROM `'._DB_PREFIX_.'category_group` WHERE `id_category` = '.$row['id_category'].' AND `id_group` = '.$row['id_group'].' LIMIT '.$limit); } else return; } }