douxun4860
2017-11-09 16:08
浏览 28
已采纳

覆盖Prestashop 1.7中的控制器

Hi I want to override a controller (in /controllers/front/MyAccountController.php) I tried different things :

  • In a custom module : /modules/my_module/override/controllers/front/MyAccountController.php

    class MyAccountController extends MyAccountControllerCore
    {
    
    
    /**
     * Assign template vars related to page content
     * @see FrontController::initContent()
     */
    public function initContent()
    {
        exit("test");
    
    }
    
  • In /override/controllers/front/MyAccountController.php

    // SAME CODE //
    

I also tried with this code :

    class MyAccountControllerCore extends FrontController
    {


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

    }

What is the correct wayto do it, please ?

图片转代码服务由CSDN问答提供 功能建议

您好我想覆盖一个控制器(在/controllers/front/MyAccountController.php中)我尝试了不同的东西:< / p>

  • 在自定义模块中:/modules/my_module/override/controllers/front/MyAccountController.php

    nn
     class MyAccountController扩展MyAccountControllerCore 
     {
     
     
     / ** 
     *分配与页面内容相关的模板变量
     * @see FrontController :: initContent()
     * / 
    共享函数initContent()
      {
     exit(“test”); 
     
    } 
        
     
  • 在/override/controllers/front/MyAccountController.php中

      // SAME CODE // 
        
      
     
     

    我也试过这个 代码:

     类MyAccountControllerCore扩展FrontController 
     {
     
     
     / ** 
     *分配与页面内容相关的模板变量
     * @see FrontController ::  initContent()
     * / 
     n公共函数initContent()
     {
     exit(“test”); 
     
    } 
       
     
     

    什么是 该 正确的方法,请吗?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongling5411 2017-11-10 06:01
    已采纳

    All this methods should work,

    Did you check the option Disable all overrides in Advanced Parameters > Performance

    screenshot

    It should be to No.

    You can also delete the file app/cache/prod/class_index.php to force PrestaShop to scan the override folder.

    打赏 评论

相关推荐 更多相似问题