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

Cleaning your code using the hook's controller

At this point, your main class, mymodcomments, should be of almost 300 lines. The following section is not a PrestaShop best practice; beware! During the next chapter, I'll use the module with hook controllers.

This is how I chose to split my code to have hook actions in a separate class. You can choose to do it differently (or not at all, in which case, you can skip this section).

Note

I have attached two versions of the module with this chapter:

  • mymodcomments: This is the module you should have now
  • mymodcomments_with_hook_controllers: This is what the module should look like once you add the hook controllers

We will create one controller for each part of our module. For example, in the case of the

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