The general idea of any update is overwriting the existing core and add-on files. That's simple. However, sometimes X-Cart needs to synchronize data or do some utility work. This is what update hooks do.

There are three types of update hooks:

  • pre-update hooks run before the files overwriting starts. These hooks work using the code of the old core.

  • post-update hooks run after the files overwriting completes, but before the cache rebuild process has started. These hooks prepare a store for the cache rebuild process and also work using the code of the old core.

  • post-rebuild hooks run after the very first cache rebuild process has finished. They work using the code of the new core.

Update hooks of the core locate in the folder <X-Cart 5>/upgrade/. For example, the folder <X-Cart 5>/upgrade/5.1/3/ stores the update hooks for version 5.1.3. There you will find three types of files:

  • pre_upgrade.php contains pre-update hooks;

  • post_upgrade.php contains post-update hooks;

  • post_rebuild.php contains post-rebuild hooks.

Update hooks may exist in the add-ons as well if an add-on needs to synchronize data between its own versions. Add-on update hooks can locate in the <X-Cart 5>/classes/Module/<DEV-ID>/<MODULE-ID>/upgrade/ folders; for example <X-Cart 5>/classes/XLite/Module/XC/ProductComparison/upgrade/.

Related pages:

Did this answer your question?