首页 > 解决方案 > Prestashop 1.7 Hook actionCustomerAccountAdd 未触发

问题描述

我正在尝试在我的自定义模块中添加一个钩子,但是在我在 prestashop 后台或使用 web 服务中添加一个客户后它没有被触发。

我要注册的钩子名称是“actionCustomerAccountAdd”。

这是模块的相关代码。请问你能帮帮我吗?我是一名 PHP 开发人员,但这是我第一次在 Prestashop 方面进行开发。

/**
     * Don't forget to create update methods if needed:
     * http://doc.prestashop.com/display/PS16/Enabling+the+Auto-Update
     */
    public function install()
    {
        return parent::install()
            && $this->createRequiredDBTables()
            && $this->registerHook('actionCustomerAccountAdd');
    }

我有这个代码来检查日志文件或页面,但它没有被触发:

public function hookActionCustomerAccountAdd($params)
    {
        $this->logger->info('Hook action customer account add fired');
        echo 'hook fired';
        die();
    }

谢谢你。

标签: phpprestashopprestashop-1.7prestashop-modules

解决方案


问题是钩子actionCustomerAccountAdd只在前台触发,你需要使用actionObjectCustomerAddAfter, 执行的动态钩子classes/ObjectModel.php


推荐阅读