Example #1
0
    private function updateCat()
    {
        $moduleName = Tools::getValue('moduleName');
        Db::getInstance()->execute('UPDATE
									' . _DB_PREFIX_ . 'category c
									INNER JOIN
									' . _DB_PREFIX_ . 'category c2
									ON
									c.id_parent = c2.`id_category_' . bqSQL($moduleName) . '`
									SET
									c.id_parent = c2.id_category
									WHERE c.`id_category_' . bqSQL($moduleName) . '` != 0');
        $category = new Category();
        $cats = $category->getSimpleCategories((int) Configuration::get('PS_LANG_DEFAULT'));
        foreach ($cats as $cat) {
            $cat = new Category((int) $cat['id_category']);
            $cat->level_depth = $cat->calcLevelDepth();
            $cat->update();
        }
    }