/** * @see Module::install() */ public function install() { /* Adds Module */ if (parent::install() && $this->registerHook('displayHeader') && $this->registerHook('displayBackOfficeHeader') && $this->registerHook('displayCategorySlider') && $this->registerHook('actionShopDataDuplication')) { /* Sets up configuration */ $res = Configuration::updateValue('CATESLIDER_WIDTH', '1170'); $res &= Configuration::updateValue('CATESLIDER_HEIGHT', '370'); $res &= Configuration::updateValue('CATESLIDER_SPEED', '1500'); $res &= Configuration::updateValue('CATESLIDER_PAUSE', '3000'); $res &= Configuration::updateValue('CATESLIDER_LOOP', '1'); /* Creates tables */ $res &= $this->createTables(); /* Adds samples */ // if ($res) // $this->installSamples() $root_cate = Category::getRootCategories($this->context->cookie->id_lang); foreach ($root_cate as $cate) { if ($cate['name'] == 'Home') { Configuration::updateValue('ROOT_CATEGORY', $cate['id_category']); break; } } return $res; } return false; }
/** * @see Module::install() */ public function install() { /* Adds Module */ if (parent::install() && $this->registerHook('displayHeader') && $this->registerHook('displayBackOfficeHeader') && $this->registerHook('displayOvicCategorySizeChart') && $this->registerHook('actionShopDataDuplication')) { $res = ''; /* Creates tables */ $res &= $this->createTables(); $root_cate = Category::getRootCategories($this->context->cookie->id_lang); foreach ($root_cate as $cate) { if ($cate['name'] == 'Home') { Configuration::updateValue('ROOT_CATEGORY', $cate['id_category']); break; } } return true; } return false; }
public function initCategoriesAssociation($id_root = null) { if (is_null($id_root)) { $id_root = Configuration::get('PS_ROOT_CATEGORY'); } $id_shop = (int) Tools::getValue('id_shop'); $shop = new Shop($id_shop); $selected_cat = Shop::getCategories($id_shop); if (empty($selected_cat)) { // get first category root and preselect all these children $root_categories = Category::getRootCategories(); $root_category = new Category($root_categories[0]['id_category']); $children = $root_category->getAllChildren($this->context->language->id); $selected_cat[] = $root_categories[0]['id_category']; foreach ($children as $child) { $selected_cat[] = $child->id; } } if (Shop::getContext() == Shop::CONTEXT_SHOP && Tools::isSubmit('id_shop')) { $root_category = new Category($shop->id_category); } else { $root_category = new Category($id_root); } $root_category = array('id_category' => $root_category->id, 'name' => $root_category->name[$this->context->language->id]); $helper = new Helper(); return $helper->renderCategoryTree($root_category, $selected_cat, 'categoryBox', false, true); }