public function initDb($id_shop) { $languages = $this->context->controller->getLanguages(); $id_lang = $this->context->language->id; $str = array(); $shop = new Shop($id_shop); $root = Category::getRootCategory($id_lang, $shop); $categs = Db::getInstance()->executeS(' SELECT c.id_category, c.id_parent, c.active FROM ' . _DB_PREFIX_ . 'category c INNER JOIN `' . _DB_PREFIX_ . 'category_shop` cs ON (cs.id_category=c.id_category AND cs.id_shop=' . (int) $id_shop . ') ORDER BY c.id_category ASC, c.level_depth ASC, cs.position ASC;'); foreach ($categs as $kc => $cat) { foreach ($languages as $key => $lang) { $str[$lang['id_lang']] = ''; } $condition = ''; $availability = ''; $gender = ''; $age_group = ''; $color = ''; $material = ''; $pattern = ''; $size = ''; $cat_exists = GCategories::get($cat['id_category'], $id_lang, $id_shop); if ((!count($cat_exists) || $cat_exists === false) && $cat['id_category'] > 0) { if ($root->id_category == $cat['id_category']) { foreach ($languages as $key => $lang) { $str[$lang['id_lang']] = $this->l('Google Category Example > Google Sub-Category Example'); } $condition = 'new'; $availability = 'in stock'; } GCategories::add($cat['id_category'], $str, $cat['active'], $condition, $availability, $gender, $age_group, $color, $material, $pattern, $size, $id_shop); } } foreach ($languages as $lang) { if (!count(GLangAndCurrency::getLangCurrencies($lang['id_lang'], $id_shop))) { GLangAndCurrency::add($lang['id_lang'], $this->context->currency->id, 1, $id_shop); } } return true; }