public function reOrderPositions($menu_type) { $id_tab = $this->id; $context = Context::getContext(); $id_shop = $context->shop->id; $max = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT MAX(hss.`position`) as position FROM `' . _DB_PREFIX_ . 'iqitmegamenu_tabs` hss, `' . _DB_PREFIX_ . 'iqitmegamenu` hs WHERE hss.`id_tab` = hs.`id_tab` AND hss.`menu_type` = ' . (int) $menu_type . ' AND hs.`id_shop` = ' . (int) $id_shop); if ((int) $max == (int) $id_tab) { return true; } $rows = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT hss.`position` as position, hss.`id_tab` as id_tab FROM `' . _DB_PREFIX_ . 'iqitmegamenu_tabs` hss LEFT JOIN `' . _DB_PREFIX_ . 'iqitmegamenu` hs ON (hss.`id_tab` = hs.`id_tab`) WHERE hs.`id_shop` = ' . (int) $id_shop . ' AND hss.`menu_type` = ' . (int) $menu_type . ' AND hss.`position` > ' . (int) $this->position); foreach ($rows as $row) { $current_tab = new IqitMenuTab($row['id_tab']); --$current_tab->position; $current_tab->update(); unset($current_tab); } return true; }
private function duplicateTab($id_tab) { $id_shop = (int) Context::getContext()->shop->id; $tab = new IqitMenuTab($id_tab); $newobject = $tab->duplicateObject(); $newobject->associateToShop($id_shop); }