Warning: You are browsing the documentation for PrestaShop 1.7, which is outdated.

You might want to look at the current version, PrestaShop 8. Read the updated version of the documentation

Learn how to upgrade to the latest version.

Backward compatibility with PrestaShop 1.6

If you plan to develop a module for PrestaShop 1.7 then extending the compatibility with previous major versions of PrestaShop, it may require some changes before being ready for production.

Namespaces

PrestaShop 1.6 does not fully support namespaces. They throw some issues when used in specific places.

  • In the main class of your module, the keyword use [...]; will trigger syntax errors when PrestaShop will try to parse the file.
  • ObjectModels can’t be defined in a namespace. The hook generated while managing this entity will be considered as invalid by the Validate class and will trigger fatal errors.

PHP API updates

The visibility of many functions have been switched to public between two versions of PrestaShop (i.e Link::getBaseLink() which was protected then public from PS 1.6.1.15). We recommend using a static analysis tool like PhpStan to detect these changes.

Templating

addCSS / addJS / jsDef may not work properly on PrestaShop 1.6.0.* when sending Json data to a template. We recommend sending your variables without trying to encode them. PrestaShop will handle them and avoid escaping issues with quotes.

$translations = [
    'dummy1' => 'Example of data',
    'dummy2' => 'Another example of data',
];

Media::addJsDef([
-    'translations' => json_encode($translations),
+    'translations' => $translations, // Data will be encoded by PrestaShop
]);