Child pages
  • Using the backward compatibility toolkit
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Using the backward compatibility module


PrestaShop's module API has greatly improved between version 1.4 and version 1.5 of the software.

Because there is a huge ecosystem of modules that are being upgraded to support the 1.5 module API while many shops are still using PrestaShop 1.4, the developers of PrestaShop chose to build Backward Compatibility, a free module which is only available for PrestaShop 1.4, and makes it possible to make 1.5 modules work in PrestaShop 1.4.

Including this module makes it possible to develop a 1.4 module that using PrestaShop 1.5 standards.

The 1.5 API's Helpers (HelperForm, HelperView, etc.) are still not available in PrestaShop 1.4.

Therefore, the following declarations are not necessary anymore:

global $smarty, $cookie;

The information they provide is available through these calls:

$this->context->smarty->assign('content', 'empty');

Download and install

You can download the Backward Compatibility module for free on PrestaShop Addons:
Unzip the file and put it the /modules folder of your installation of PrestaShop 1.4.

You can else get it directly from PrestaShop's repository:
Just clone the project on your own repository, then copy the content of the folder to the root folder of the module.

You do not have to click "Install" on this module in PrestaShop's "Modules" administration.

It is useless the install the module in PrestaShop 1.5.

How to use the module

To properly us the module, you must first declare it in the module constructor method:

public function __construct()
    $this->name = 'testmodule';
    $this->tab = 'other';
    $this->version = '0.1';
    $this->author = 'Firstname Lastname';
    $this->need_instance = 0;


    $this->displayName = $this->l('Test module');
    $this->description = $this->l('This is a test module');
    $this->confirmUninstall = $this->l('Warning: all the data saved in your database will be deleted. Are you sure you want uninstall this module?');

    /* Backward compatibility */
    if (_PS_VERSION_ < '1.5')
        $this->backward_error = $this->l('In order to work properly in PrestaShop v1.4, the Test module requiers the backward compatibility module at least v0.3.').'<br />'.
            $this->l('You can download this module for free here:');
        if (file_exists(_PS_MODULE_DIR_.'backwardcompatibility/backward_compatibility/backward.php'))
            $this->backward = true;
            $this->warning = $this->backward_error;
        $this->backward = true;

Once this is in place, you can call $this->backward and $this->backward_error in your module in order to pinpoint 1.5- or 1.4-specific code:

public function install()
    if (!$this->backward && _PS_VERSION_ < 1.5)
        echo '<div class="error">'.Tools::safeOutput($this->backward_error).'</div>';
        return false;


...or if you want to prevent code from being used under PrestaShop 1.4 as long as the Backward Compatibility module is not available:

/* If 1.4 and no backward, then leave */
if (!$this->backward)
  • No labels