Child pages
  • New Developers Features In PrestaShop 1.5

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

There are six main aspects of PrestaShop's Module API which received a significant overhaul for version 1.5: dynamic hooks, evolution of the override system, new filetree file-tree and operations, multishop feature, Addons webservice, and the update system. We will explore these one by one.

...

  • easier to manage, install, and share along with the module itself.
  • multiple modules can make changes to the core classes, as long as they do not attempt to override the same functions.

New

...

File-tree And Operations

In previous version of PrestaShop, there could be situations when you would have to call one of the module's file directly. For instance, when paying with the Cheque module, you would have to reach such a URL: http://myprestashop.com/modules/cheque/payment.php

...

This is achieved by using FrontController classes in your module. In the example of the Cheque module, the following file has been place in the module's filetreefile-tree:
/modules/cheque/controllers/front/payment.php

...

Generally speaking, a PrestaShop 1.5 module should now use the following filetreefile-tree:

  • /config.xml: Automatically created by PrestaShop when the module is loaded.
  • /mymodule.php
  • /mymodule.jpg: Logo file, 16*16 pixels. For versions of PrestaShop up to v1.4.
  • /mymodule.png: Logo file, 32*32 pixels. For PrestaShop 1.5 and later.
  • /controllers/
  • /controllers/front/myfile.php: As explained above.
  • /translations/
  • /translations/fr.php: French language file, created automatically when you start translating the module in your back-office.
  • /translations/de.php: Deutsh language file, created automatically when you start translating the module in your back-office.
  • /translations/...: ...and so on...
  • /views/
  • /views/css/: For CSS files.
  • /views/js/: For JavaScript files.
  • /views/templates/front/: For template files used by the module's controllers.
  • /views/templates/hooks/: For template files directly used by the module. For backward compatibility purposes, this type of files can also be placed in the root folder of the module.

...

Code Block
<?php
// Sample file for module update

if (!defined('_PS_VERSION_'))
  exit;

// object module ($this) available
function upgrade_module_1_8_0($object)
{
  // your update code from previous version
}
?>

When updating, PrestaShop will call all your update files one after the other, from the current version to the latest version. For instance, let's say the module's /upgrade folder contains the following files:

...