maria zagula Posted April 6, 2016 Share Posted April 6, 2016 Hi experts ! I would like to set category page as home page exactly as it was described here http://stackoverflow.com/questions/19012800/how-to-set-category-page-as-home-page-in-prestashop The problem is (probably) that the solution is from 2013 and it is not working on Prestashop 1.6 In my prestashop 1.6 file controllers/front/IndexController.php looks like that class IndexControllerCore extends FrontController { public $php_self = 'index'; /** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->addJS(_THEME_JS_DIR_.'index.js'); $this->context->smarty->assign(array('HOOK_HOME' => Hook::exec('displayHome'), 'HOOK_HOME_TAB' => Hook::exec('displayHomeTab'), 'HOOK_HOME_TAB_CONTENT' => Hook::exec('displayHomeTabContent') )); $this->setTemplate(_PS_THEME_DIR_.'index.tpl'); } } Please help and thanks in advance Maria Link to comment Share on other sites More sharing options...
roja45 Posted April 6, 2016 Share Posted April 6, 2016 This seems to work in the index controller, as in the first example on stack exchange. So it should work in an override class as well. Tools::redirect($this->context->link->getCategoryLink( <your-category-id )); Link to comment Share on other sites More sharing options...
maria zagula Posted April 8, 2016 Author Share Posted April 8, 2016 Thanks ! Link to comment Share on other sites More sharing options...
CrossY Posted April 12, 2016 Share Posted April 12, 2016 This seems to work in the index controller, as in the first example on stack exchange. So it should work in an override class as well. Tools::redirect($this->context->link->getCategoryLink( <your-category-id )); Thanks for the help, however it's not working for me it seems. I have the following code now, what am I missing? I cleared cache through the BO as well, but index just gives me the same page as before. It's in override as well, so that doesn't seem to be the issue. public function initContent() { parent::initContent(); Tools::redirect($this->context->link->getCategoryLink( <3 )); $this->context->smarty->assign('HOOK_HOME', Hook::exec('displayHome')); $this->setTemplate(_PS_THEME_DIR_.'index.tpl'); } Any suggestions? Would be much appreciated! Link to comment Share on other sites More sharing options...
roja45 Posted April 12, 2016 Share Posted April 12, 2016 the variable for the category link should be an integer only and the code after the Tools::redirect shouldn't be there, though I doubt it is being executed. You should also check that the override is being called, you have to delete the class_index.php in the cache directory file, I believe, but I don't use overrides. There are other posts about getting overrides working on this forum. Link to comment Share on other sites More sharing options...
CrossY Posted April 12, 2016 Share Posted April 12, 2016 Thanks for the quick reply, I solved it with a solution from Vekia (another topic, lost it) Replace the content of the IndexController.php with the following. Works up to 1.6.1.4 at least: class IndexControllerCore extends CategoryController { public $php_self = 'index'; /** * Assign template vars related to page content * @see FrontController::initContent() */ public function init(){ $_GET['id_category']=3; parent::init(); } public function initContent() { parent::initContent(); } } Change the number '3' to whichever category ID you'd like to redirect. Link to comment Share on other sites More sharing options...
maria zagula Posted April 12, 2016 Author Share Posted April 12, 2016 Thanks ! Your solutions works but right now I have adress of my homepage "www.myshopname.com/en/3-women" rather then simple "www.myshopname.com". Is there a possibility to set homepage to category 3 but preserving at the same time original simple homepage adress ? Link to comment Share on other sites More sharing options...
CrossY Posted April 12, 2016 Share Posted April 12, 2016 Hmm, I would assume it's possible with a htaccess rewrite, but I have no idea how that works. Would be neat if someone could figure that out for us Link to comment Share on other sites More sharing options...
quendi Posted June 8, 2022 Share Posted June 8, 2022 (edited) As if someone was looking for 1.7.x it also works. To make simple URL, add: public function canonicalRedirection($canonicalURL = ''){ } Edited June 8, 2022 by quendi (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now