Question

I have a problem with my Prestashop, i would like to create a webpage in a module without using the CMS.

But when I want to access the controller by using this Url : http://example.com/comparateur/module/ProduitsMarchand/ProductList

I have that message & when i click on the link, i have a 404 error

[Debug] This page has moved
Please use the following URL instead: http://example.com/comparateur/index.php?controller=ProductList&module=ProduitsMarchand

My controller looks like this

class ProduitsMarchandProductListModuleFrontController extends ModuleFrontController {

    public $php_self ="ProductList";
    /**
     *  Initialize controller
     *  @see FrontController::init()
     */
    public function init() {
        parent::init();
    }

    /**
     *  Assign template vars related to page content
     *  @see FrontController::initContent()
     */
    public function initContent() {
        parent::initContent();

        $this->setTemplate("ProductList.tpl");
    }
}

Preferences > SEO & URLs

Page: produitsmarchands - productlist
URL: product-list
Was it helpful?

Solution

You got a few fundamental mistakes.

First of all you should'nt be using FrontController but rather ModuleFrontController. Since you are extending a module not a fully sepearate new controller.

Next thing is that your class is wrong. It should be something similar to this.

YourModuleNameYourControllerNameModuleFrontcontroller

YourModuleName = name of your module

YourControllername = name of your controller and should be located in yourmodule/controllers/front

And last but not least this is completely wrong

$this->setTemplate(__FILE__.'/../../../views/templates/front/ProductList.tpl');

You should use this

$this->setTemplate('ProductList.tpl');

That way your file will be located in yourmodule/views/templates/front

And if you have followed all of those guidelines you should be able to set a friendly url for your moduelController in Preferences -> SEO & URL

BR's

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top