public function process() { parent::process(); if (!($id_category = (int) Tools::getValue('id_category')) or !Validate::isUnsignedId($id_category)) { $this->errors[] = Tools::displayError('Missing category ID'); } else { if (!Validate::isLoadedObject($this->category)) { $this->errors[] = Tools::displayError('Category does not exist'); } elseif (!$this->category->checkAccess((int) self::$cookie->id_customer)) { $this->errors[] = Tools::displayError('You do not have access to this category.'); } elseif (!$this->category->active) { self::$smarty->assign('category', $this->category); } else { $rewrited_url = self::$link->getCategoryLink((int) $this->category->id, $this->category->link_rewrite); /* Scenes (could be externalised to another controler if you need them */ self::$smarty->assign('scenes', Scene::getScenes((int) $this->category->id, (int) self::$cookie->id_lang, true, false)); /* Scenes images formats */ if ($sceneImageTypes = ImageType::getImagesTypes('scenes')) { foreach ($sceneImageTypes as $sceneImageType) { if ($sceneImageType['name'] == 'thumb_scene') { $thumbSceneImageType = $sceneImageType; } elseif ($sceneImageType['name'] == 'large_scene') { $largeSceneImageType = $sceneImageType; } } self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL); self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL); } $this->category->description = nl2br2($this->category->description); $subCategories = $this->category->getSubCategories((int) self::$cookie->id_lang); self::$smarty->assign('category', $this->category); if (Db::getInstance()->numRows()) { self::$smarty->assign('subcategories', $subCategories); self::$smarty->assign(array('subcategories_nb_total' => sizeof($subCategories), 'subcategories_nb_half' => ceil(sizeof($subCategories) / 2))); } if ($this->category->id != 1) { $nbProducts = $this->category->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); $this->pagination((int) $nbProducts); self::$smarty->assign('nb_products', (int) $nbProducts); $cat_products = $this->category->getProducts((int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay); if ($cat_products) { foreach ($cat_products as $cat_product) { $prod_features[$cat_product["id_product"]] = Product::getFrontFeaturesStatic(self::$cookie->id_lang, $cat_product['id_product']); $aux_product = new Product($cat_product["id_product"], true, self::$cookie->id_lang); $aux_attributesGroups = $aux_product->getAttributesGroups((int) self::$cookie->id_lang); foreach ($aux_attributesGroups as $k => $row) { $aux_combinations[$row['attribute_name']]['price'] = (double) $row['price']; } $prod_combinations[$cat_product["id_product"]] = $aux_combinations; unset($aux_combinations); } } } if (isset($prod_features)) { self::$smarty->assign('prod_features', $prod_features); } if (isset($prod_combinations)) { self::$smarty->assign('prod_combinations', $prod_combinations); } self::$smarty->assign(array('products' => (isset($cat_products) and $cat_products) ? $cat_products : NULL, 'id_category' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath((int) $this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize('category'), 'mediumSize' => Image::getSize('medium'), 'thumbSceneSize' => Image::getSize('thumb_scene'), 'homeSize' => Image::getSize('home'))); foreach ($subCategories as $subCat) { $secondLevelCats[$subCat["id_category"]] = $this->getSubCats($subCat["id_category"]); } if (isset($secondLevelCats)) { self::$smarty->assign('secondLevelCats', $secondLevelCats); } } } self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers())); }