Child pages
  • Using the backward compatibility toolkit

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

...

Code Block
$this->context->customer->id;
$this->context->language->id;
$this->context->smarty->assign('content', 'empty');
...

Download and install

You can download the Backward Compatibility module for free on PrestaShop Addons: http://addons.prestashop.com/en/administration-tools-prestashop-modules/6222-backward-compatibility.html
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: https://github.com/PrestaShop/PrestaShop-backward_compatibility
Just clone the Git project on your own repository, then copy the content of the folder to the root folder of the module you are developing.

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

...

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

    parent::__construct();

    $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: http://addons.prestashop.com/en/modules-prestashop/6222-backwardcompatibility.html');
        if (file_exists(_require(_PS_MODULE_DIR_.'backwardcompatibility/backward_compatibility/backward.php'))
        {
            include(_PS_MODULE_DIR_.'backwardcompatibility$this->name.'/backward_compatibility/backward.php');
            $this->backward = true;
        }
        else
            $this->warning = $this->backward_error;
    }
    else
        $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:

Code Block
public function install()
{
    if (!$this->backward && _PS_VERSION_ < 1.5)
    {
        echo '<div class="error">'.Tools::safeOutput($this->backward_error)>l('In order to work properly in PrestaShop v1.4, the Test module requires the Backward Compatibility module 0.3+.')).'</div>';
        return false;
    }

    ...

...