Categories
PrestaShop Custom Development

How to know which hooks are used in the current page of PrestaShop? -Enumeration lists all hooks used by PrestaShop.

As a PrestaShop developer for more than 10 years, I want to share this cheat. This cheat is really cool and can help you quickly find the hooks you want to use. We are often troubled by not knowing which hooks can be used on the current page of PrestaShop, resulting in Can’t develop a great PrestaShop module, well now, you’re in luck, I’ll tell you.

1.classes/Hook.php

To change the above file, you can use the IDE to search for function exec and quickly find the exec method of about 776 lines. Below the method content, we print out the name of the currently used hook.
Input: var_dump($hook_name);

2.congratulations.
At this point, you’ve finished writing great code! Remember to save the file.
At this time, when you open the front-end or back-end of your website and browse any page at will, you will be surprised to see that the page outputs a list of all available PrestaShop hooks.

3.Oh, my God!

It looks a bit messy like this, let’s open the source code and take a look.

Wow, isn’t that cool? When you are developing a PrestaShop module, you can easily find out which hooks are used on the current page. You can happily enter module development and develop the best modules in the world, improving development efficiency, and you don’t have to worry because the PrestaShop manual and Many misunderstandings caused by the mismatch between your development versions.

Whether it is PrestaShop 1.6 version, PrestaShop 1.7, 8.X or the future PrestaShop 9 version, this method is applicable and will not fail due to different versions. It has greatly improved the work efficiency of PrestaShop developers, and I hope it can be helpful to everyone.

Leave a Reply

Your email address will not be published. Required fields are marked *