在 Prestashop 1.7 中覆盖控制器

Overriding controllers in Prestashop 1.7

嗨,我想覆盖控制器(在 /controllers/front/MyAccountController.php 中)我尝试了不同的东西:

我也试过这个代码:

    class MyAccountControllerCore extends FrontController
    {


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

    }

请问正确的做法是什么?

所有这些方法都应该有效,

您是否在“高级参数”>“性能”中选中“禁用所有覆盖”选项

应该是第

您也可以删除文件 app/cache/prod/class_index。php 以强制 PrestaShop 扫描覆盖文件夹。

要覆盖 MyAccountController 控制器,您需要扩展 MyAccountControllerCore class 并在 initContent 函数中添加 parent::initContent() 并清除缓存它可能会起作用。