Jump to content

actionAjaxDieBefore hook visible on 1.7?


Tu Chu

Recommended Posts

Hi all,

I found some documents about actionAjaxDieBefore hook. In DevDocs, I saw it deprecated since 1.6.1.1 (https://devdocs.prestashop.com/1.7/modules/concepts/hooks/list-of-hooks/).
However, in another document, I find it still visible in 1.7 (http://build.prestashop.com/news/new-updated-hooks-1-7-1-0/). Even, in 1.7's code, I saw it in file classes/controller/Controller.php

I can't handle actionAjaxDieBefore hook. However, I can handle ActionAjaxDieCartControllerDisplayAjaxRefreshBefore (actionAjaxDie<ControllerName><Method>Before).

I don't know why actionAjaxDieBefore not work?

Edited by Tu Chu (see edit history)
Link to comment
Share on other sites

This hook does not automatic apply for any controllers.

Prestashop wrote it in controller.php, so if you want use it, you can call it

But it is NOT automatic called for every controller,

Example, you can open file: classes\controller\ProductListingFrontController.php

and see line:  $this->ajaxDie(json_encode($this->getAjaxProductSearchVariables()));

 

 

Link to comment
Share on other sites

48 minutes ago, tdsoft said:

This hook does not automatic apply for any controllers.

Prestashop wrote it in controller.php, so if you want use it, you can call it

But it is NOT automatic called for every controller,

Example, you can open file: classes\controller\ProductListingFrontController.php

and see line:  $this->ajaxDie(json_encode($this->getAjaxProductSearchVariables()));

 

 

But ajaxDie function call this hook:

protected function ajaxDie($value = null, $controller = null, $method = null)
{
    if ($controller === null) {
        $controller = get_class($this);
    }

    if ($method === null) {
        $bt = debug_backtrace();
        $method = $bt[1]['function'];
    }

    /* @deprecated deprecated since 1.6.1.1 */
    Hook::exec('actionAjaxDieBefore', array('controller' => $controller, 'method' => $method, 'value' => $value));

    /**
     * @deprecated deprecated since 1.6.1.1
     * use 'actionAjaxDie'.$controller.$method.'Before' instead
     */
    Hook::exec('actionBeforeAjaxDie'.$controller.$method, array('value' => $value));
    Hook::exec('actionAjaxDie'.$controller.$method.'Before', array('value' => $value));

    die($value);
}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...