模块控制器重定向到404 Prestashop

模块控制器重定向到404 Prestashop

问题描述:

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

我的Prestashop有问题,我想在不使用CMS的情况下在模块中创建网页。

但是当我想使用此Url访问控制器时: http://example.com/comparateur/module/ProduitsMarchand/ProductList p>

我有这样的信息& 当我点击链接时,我有404错误 p>

  [Debug]此页面已移动
请使用以下网址:http://example.com/comparateur  /index.php?controller=ProductList&module=ProduitsMarchand
nn

我的控制器看起来像这样 p>

 类ProduitsMarchandProductListModuleFrontController 扩展ModuleFrontController {
 
 public $ php_self =“ProductList”; 
 / ** 
 *初始化控制器
 * @see FrontController :: init()
 * / 
 n公共函数init(){
  parent :: init(); 
} 
 
 / ** 
 *分配与页面内容相关的模板变量
 * @see FrontController :: initContent()
 * / 
 n公共函数initContent(){  
 parent :: initContent(); 
 
 $ this-> setTemplate(“ProductList.tpl”); 
} 
} 
  code>  pre> 
 
 

偏好> SEO& 网址 p>

 页面:produitsmarchands  -  productlist 
URL:product-list 
  code>  pre> 
  div>

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