public function preProcess() { if ($id_category = (int) Tools::getValue('id_category')) { $this->productSort(); if ($this->category->id != 1) { $brand_id = Tools::getValue('brand'); $this->category = new Category($id_category, self::$cookie->id_lang); $nbProducts = 0; $this->n = (int) Configuration::get('PS_PRODUCTS_PER_PAGE'); $this->p = abs((int) Tools::getValue('p', 1)); try { global $cart, $cookie; $id_country = (int) Country::getDefaultCountryId(); if ($cart->id_address_delivery) { $address = new Address($cart->id_address_delivery); if ($address->id_country) { $id_country = $address->id_country; } elseif (isset($cookie->id_country)) { $id_country = (int) $cookie->id_country; } } self::$smarty->assign('price_tax_country', $id_country); $products = SolrSearch::getCategoryProducts($id_category, $brand_id, $nbProducts); } catch (Exception $e) { self::$smarty->assign('fetch_error', 1); } $this->pagination((int) $nbProducts); self::$smarty->assign('nb_products', (int) $nbProducts); $this->cat_page_products = $products; } } if (!Validate::isLoadedObject($this->category)) { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); } else { // Automatically redirect to the canonical URL if the current in is the right one // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain $currentURL = self::$link->getCategoryLink($this->category); $currentURL = preg_replace('/[?&].*$/', '', $currentURL); if (!preg_match('/^' . Tools::pRegexp($currentURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) { header('HTTP/1.0 301 Moved'); if (defined('_PS_MODE_DEV_') and _PS_MODE_DEV_) { die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $currentURL . '">' . $currentURL . '</a>'); } Tools::redirectLink($currentURL); } } parent::preProcess(); if ((int) Configuration::get('PS_REWRITING_SETTINGS')) { if ($id_category = (int) Tools::getValue('id_category')) { $rewrite_infos = Category::getUrlRewriteInformations((int) $id_category); $default_rewrite = array(); foreach ($rewrite_infos as $infos) { $default_rewrite[$infos['id_lang']] = self::$link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']); } self::$smarty->assign('lang_rewrite_urls', $default_rewrite); } } }
public function preProcess() { parent::preProcess(); try { $total_found = 0; $curated_products = SolrSearch::getCategoryProducts(CAT_CURATED, $brand_id = false, $total_found, $p = 1, $n = 500); $right_products = array_slice($curated_products, $total_found * 0.48); $left_products = array_slice($curated_products, 0, $total_found * 0.48); self::$smarty->assign('curated_products_right', $right_products); self::$smarty->assign('curated_products_left', $left_products); } catch (Exception $e) { } }