Jump to content

Set category as homepage


Recommended Posts

 

This tutorial should do the job.

Also create an override, don't modify the IndexController directly because when you update prestashop this file will be re-written.

 

More information about overrides here: http://doc.prestashop.com/display/PS16/Overriding+default+behaviors

Edited by Catalin Scaesteanu (see edit history)
Link to comment
Share on other sites

I pasted the summary code at the bottom of the tutorial and now home page returns 404.

I just tested it on a fresh install of ps v1.6.1.0 and it's working.

You might get 404 error because you set the wrong category id.

Make sure this is set correctly $_GET['id_category'] = 3; -> 3 in this case is the id of Women category from default PrestaShop, yours might be something else.

Link to comment
Share on other sites

class IndexController extends IndexControllerCore
{
	class IndexControllerCore extends CategoryController
	{
	 public $php_self = 'index';
	/**
	 * Assign template vars related to page content
	 * @see FrontController::initContent()
	 */
	 public function init(){
	 $_GET['id_category']=12;
	 parent::init();
	 }
	 public function initContent()
	 {
	 parent::initContent();
	 }
	}
}

Sorry to suck so much at coding, but for the override, do I have to place <?php before class IndexController extends IndexControllerCore?

It worked when I directly edited IndexController.php, but now that I'm doing it with an override, it doesn't work with or without <?php

Edited by dude12 (see edit history)
Link to comment
Share on other sites

Yes you need <?php starting tag in every .php file.

 

1. Create an empty file IndexController.php in /root/override/controllers/front/

2. Add the following code to the file:

<?php


class IndexController extends CategoryControllerCore {


    public $php_self = 'index';


    /**
     * Assign template vars related to page content
     * @see FrontController::initContent()
     */
    public function init() {
        $_GET['id_category'] = 12;
        parent::init();
    }


    public function initContent() {
        parent::initContent();
    }


}
 
3. Delete file: /root/cache/class_index.php
4. Reload homepage :)
Edited by Catalin Scaesteanu (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...