Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How add auto update functionality to prestashop plugin

I've create my first plugin for prestashop. I want to add autoupdate functionality for autoupdate as do for example eBay module.

enter image description here

I did not found anything about that on documentation.

like image 736
Claudio Ɯǝıs Mulas Avatar asked Jan 12 '23 11:01

Claudio Ɯǝıs Mulas


1 Answers

I've been struggeling to figure out the correct process for this for a while. I thought the "upgrade it" button was only available for developers, who release their modules through the prestashop addons website (which is true) but if you chose not to publish there, here's how you update your own modules:

In the main file of your model, within the contructor method, you must have this line of code:

 $this->version = '1.0.0';
  • make a subdirectory in your module folder called upgrade
  • create a new file in this directory called install-1.0.1.php
  • put this code in the file:

<?php
  if (!defined('_PS_VERSION_'))
    exit;

  function upgrade_module_1_0_1($object, $install = false)
  {
    //your code here, for example changes to the DB...
    return true; //if there were no errors
  }
?>

  • In your main file, change it to $this->version = '1.0.1';
  • Create a zip file of your module folder
  • Navigate to the Modules page on your stores back end, and say "upload new module"
  • Upload the zip file

Now you should see 2 messages:

The module was successfully downloaded.

and

The following module(s) were upgraded successfully:

MyModule :

Current version: 1.0.1

1 file upgrade applied

like image 159
olli Avatar answered Jan 28 '23 04:01

olli