带有 id_product 的 prestashop 自定义模块挂钩

prestashop custom module hook with id_product

我正在开发一个自定义模块,用于在产品缺货时添加按钮 "notify me"。 这个按钮应该简单地调用一个动作并写入一个自定义 table(由这个模块创建)

我的问题是将 id_product 传递给 hook

public function install() {

    $sql= "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."fasys_notify`(
    `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `title` VARCHAR(256) NOT NULL )";


    if (parent::install() == false ||  
            !$this->registerHook('notify') ||
            !$this->registerHook('displayHeader') ||
            !Db::getInstance()->Execute($sql)
        )
        return false;
        return true;
}



public function hookFasysNotify($params) {

    //NEED ID_PRODUCT HERE

    //var_dump(Tools::getValue('id_product')); //doesen't works

    $html ='<button type="button" class="notifyme_btn btn btn-info btn-default">Notify Me</button>';

    return $html ;  

}

在我的 .tpl 文件中我添加了这个:

{hook h='fasysNotify' product=$product}

如何取回产品?

.tpl

{hook h='fasysNotify' product=$product}

模块:

public function hookNotify($params) {

    var_dump( $params['product']  );
}

在 tpl 中:

{hook h='fasysNotify' product=$product}

{hook h='fasysNotify' product=$id_product}

在模块中:

$id_product = $param['id_product'];

$id_product = $param;