Child pages
  • Auto-updating modules
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Auto-updating modules

Since PrestaShop 1.5, it possible to have your module auto-update: once a new version is available on Addons, PrestaShop suggests an "Update it!" button to the user. Clicking this button will trigger a series of methods, each leading closer to the latest version of your module.

In order to bring auto-update support to your module, you need three main things:

  • Clearly indicate the module's version number in its constructor method: $this->version = '1.1';
  • Create an /upgrade sub-folder in the module's folder.
  • Add an auto-update PHP script for each new version.

For instance:

/*
* File: /upgrade/Upgrade-1.1.php
*/
function upgrade_module_1_1($module) {
  // Process Module upgrade to 1.1
  // ....
  return true; // Return true if succes.
}

...and then:

/*
* File: /upgrade/Upgrade-1.2.php
*/
function upgrade_module_1_2($module) {
  // Process Module upgrade to 1.2
  // ....
  return true; // Return true if succes.
}

Each method should bring the necessary changes to the module's files and database data in order to reach the latest version. PrestaShop will then parse all of these scripts one after the other, sequentially.

It is therefore highly advised to number your module's versions sequentially, and using only number.

  • No labels