Child pages
  • Fundamentals

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Table of contents

Table of Contents
maxLevel2

Fundamentals

Concepts

Tip

You should be familiar with PHP and Object-Oriented Programming before attempting to write your own module.

PrestaShop was conceived so that third-party modules could easily upon its foundations, making it an extremely customizable e-commerce software.

A module is a complement an addition to PrestaShop that enables any developer to add the following:

...

The company behind PrestaShop provides more than 50 100 modules for free with the tool itself, enabling you to launch your business quickly and for free.

More than 750 add-ons are also available at the official add-ons site.
These additional modules were build ??built by the PrestaShop company PrestaShop or members of the PrestaShop community, and are sold at affordable prices.
As a developer, you can also share your modules on this site, and receive 70% of the amounts associated with the sale of your creations. Sign up now!

Technical principles behind a module

A module consists of:

  • A root folder, named after the module, which will hold all of the modules files, and will reside in PrestaShop's /modules folder.
  • A main PHP file, named after the module, located in that root folder. This PHP file should have the same name as its root folder.
  • An icon file, named logo.gif, representing this module.
  • Optional: some .tpl files, containing the module's theme.
  • Optional: language files, if the module of its theme have text to display (and therefore, that should be translatable).
  • Optional: in a /themes/modules, a folder with the same name as the module, containing .tpl and language files if necessary. This last folder is essential during modifications of existing module, so that you can adapt it without having to touch its original files. Notably, it enables you to handle the module's display in various ways, according to the current theme.

Let's see an example with PrestaShop's blockuserinfo module:

PrestaShop's technical architecture

PrestaShop is based on a 3-tier architecture:

  • Object/data. Database access is controlled through files in the "classes" folder.
  • Data control. User-provided content is controlled by files in the root folder.
  • Design. All of the theme's files are in the "themes" folder.

Image Added

This is the same principle as the Model–view–controller (MVC) architecture, only in a simpler and more accessible way.

Our developer team chose not to use a PHP framework, such as Zend Framework, Symfony or CakePHP, so as to allow for better readability, and thus faster editing.

This also makes for higher performances, since the software is only made of the lines of code it requires, and does not contain a bunch of supplemental generic libraries.

A 3-tier architecture has many advantages:

  • It's easier to read the software's code.
  • Developers can add and edit code faster.
  • Graphic designer and HTML integrators can work with the confines of the /themes folder without having to understand or even read a single line of PHP code.
  • Developers can work on additional data and modules that the HTML integrators can make use of.

Database schema

Image Added

You can download the PrestaShop 1.4.7.2 SQL schema in PNG form (8 Mb), or in the original MySQL Workbench file format (you will need MySQL Workbench to view it).