Chapter 4. Building Module Updates

In Chapter 2, Hooks, to create a SQL table, we used phpMyAdmin (any SQL manager tool will do). However, you will agree that it isn't very handy for the merchant who wants to install the module. There are no PrestaShop official methods to create, delete, or update a database table in a module. I will show you the one used in most of the native PrestaShop modules.

In this chapter, we will see how to do the following:

  • Create a SQL table when the module is installed
  • Delete a SQL table when the module is uninstalled
  • Alter the existing SQL table when the module is updated

Creating a database table on module installation

First of all, we will create a directory named install in the module directory. In this directory, create ...

Get PrestaShop Module Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.