Jump to content

Autoupdate moduli


k7dev

Recommended Posts

Salve a tutti, ho sviluppato un modulo per prestashop che vorrei pubblicare sul sito ufficiale degli addons e sarei pronto se non fosse che ho dei dubbi sulle funzionalità di autoupdate. In sostanza ho capito che bisogna creare la cartella 'upgrade' con uno script appositamente nominato x distinguere da una versione all'altra. Negli esempi della documentazione è chiaro cosa si può fare quando viene richiamato lo script e la funzione associata ma non ho compreso se è possibile agire sui file che compongono il modulo x cambiare il sorgente visto che la documentazione stessa riporta quanto segue:

 

 

PrestaShop will then parse all of these scripts one after the other, sequentially. It is therefore highly advised to number your module's versions sequentially, and to only use numbers – because the upgrade code uses PHP's version_compare() method.

 

If the new version of your module adds or update its hooks, you should make sure to update them too

Indeed, since the hooks are (usually) defined when the module is installed, PrestaShop will not install the module again in order to include the new hooks' code, so you have to use the upgrade methods:

 

For instance, here's the install-1.2.php file from the blockbestseller module:

<?php
if (!defined('_PS_VERSION_'))
    exit;
 
function upgrade_module_1_2($object)
{
    return ($object->registerHook('addproduct')
      && $object->registerHook('updateproduct')
      && $object->registerHook('deleteproduct')
      && $object->registerHook('actionOrderStatusPostUpdate'));
}

 

Adesso io da questo esempio capisco come dai precedenti che posso intervenire per allineare il DB per eventuali modifiche a tabelle e creazione di nuove tabelle se necessario o posso registrare altri hook etc etc ma è come se eventuali modifiche al codice sorgente dovessi farle direttamente manipolando i files con php. Mi sbaglio? Se sì, qualcuno sa gentilmente spiegarmi quale sarebbe l'approccio giusto ed eventuali suggerimenti sarebbero graditissimi. Grazie anticipatamente a tutti :)

Link to comment
Share on other sites

  • 2 weeks later...

Ciao, credo che per pubblicare il tuo modulo suPrestashop devi esser un prestashop partner.

 

Cosa fa il tuo modulo?

 

grazie per l'interessamento, ma poco dopo aver postato ho capito il funzionamento degli aggiornamenti almeno per quello che mi serve sapere.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...