prestashop category as homepage code example

Example 1: prestashop category as homepage

/* 
 * Better way with overide
 * 1. Create file override/controllers/front/IndexController.php
 * 2. Insert code
 * 3. Remove file cache/class_index.php
 */
class IndexControllerCore extends FrontController {
  public function initContent() {
  	Tools::redirect('index.php?id_category=3&controller=category');
  }
}

Example 2: prestashop category as homepage

/* Quick and dirty
 * in file Controllers/IndexController.php
 */
public function initContent() {
   parent::initContent();
   Tools::redirect('index.php?id_category=10&controller=category');
   $this->context->smarty->assign('HOOK_HOME', Hook::exec('displayHome'));
   $this->setTemplate(_PS_THEME_DIR_.'index.tpl');
}

Tags:

Php Example