Warning: You are browsing the documentation for PrestaShop 1.7, which is outdated.
You might want to look at the current version, PrestaShop 8.
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.
PrestaShop 1.6 does not fully support namespaces. They throw some issues when used in specific places.
use [...];will trigger syntax errors when PrestaShop will try to parse the file.
Validateclass and will trigger fatal errors.
The visibility of many functions have been switched to
public between two versions of PrestaShop (i.e
Link::getBaseLink() which was
public from PS 188.8.131.52).
We recommend using a static analysis tool like PhpStan to detect these changes.
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 ]);