O'Reilly logo

PrestaShop Module Development by Fabien Serny

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The dynamic hooks

As you saw in the previous part and in the PrestaShop source code, when a hook is called, the hook name is generally hardcoded. For example, this hook call will always be used to display something on the left column:

Hook::exec('displayLeftColumn');

However, you will find that in some part of the software, there are hooks whose names are constructed dynamically. You will find them in abstract classes such as ObjectModel and AdminController, or admin helper templates such as form.tpl and view.tpl.

Let's take the ObjectModel class (/classes/ObjectModel.php) as an example. If we search for the first Hook::exec method in the file, we will find the following two hooks, one beside the other at the beginning of the add method:

Hook::exec('actionObjectAddBefore', ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required