What PrestaShop is
PrestaShop is a free, open-source online shop engine written in PHP. Right after installation it has a product catalogue, a cart, a checkout, customers and a back office. A developer does not write a shop from scratch but extends a ready one.
The course targets PrestaShop 8. Differences in version 9 are mentioned where they matter.
What you need
| What | Version |
|---|---|
| PHP | From 7.2.5 to 8.1 for PrestaShop 8 |
| Database | MySQL 5.6 or newer, or MariaDB |
| Web server | Apache or Nginx |
| Composer | Needed for module classes in the src folder |
PrestaShop 9 requires PHP 8.1 or newer.
What a developer does
You must not edit the files of the engine itself: a shop upgrade replaces them with new ones. All your code lives in two places.
| Where | What is done there |
|---|---|
A module — a folder in modules | Adds logic: blocks on pages, new pages, tables, settings |
A theme — a folder in themes | Changes the look: templates, styles, scripts |
Most of the course is about a module; the theme has its own lesson.
What we will build
One example runs through the whole course — the acmehello module in the modules/acmehello folder. First it prints a greeting on the home page, then it grows into a product reviews module:
- a block of reviews on the product page;
- a settings page in the back office;
- its own database table;
- a page with the list of reviews and a form;
- a back office section for managing reviews.
Every lesson adds one file or one method to the module. Where the file lives and how to see the result is stated next to each example.
What module code looks like
The shortest module is one class in one file:
// modules/acmehello/acmehello.php
class AcmeHello extends Module
{
public function __construct()
{
$this->name = 'acmehello';
$this->version = '1.0.0';
parent::__construct();
$this->displayName = 'Greeting';
}
}This is enough for the module to appear in the module list of the back office. Every line is explained in the lesson "The first module".
Where to look for answers
| Source | What is there |
|---|---|
devdocs.prestashop-project.org | The developer documentation |
The modules folder of a fresh install | Dozens of standard modules — ready samples |
The classes folder | The source of the classes a module calls |
Reading the code of standard modules is normal practice: their names start with ps_, for example ps_banner.
Common mistake
The fastest way to change something is to edit a core file or a file of the standard classic theme. It works until the first upgrade, which puts the files back to their original state. Add logic with a module and change the look in a child theme.