Search code examples
phpprestashopprestashop-1.7

How to reset cache and override in a PrestaShop custom module?


I am developping a PrestaShop (1.7.6) module that uses an override for the ps_emailsubscription native module.

However, as I am upgrading the module to a new version, I changed the override function and I know that when there is an override in a module, this override is only copied to the root override folder during the installation of the module.

Is there a way to specify that a new version of the override exist and forcing the update?

Also, in the same process, is there a way to force clear the cache during an upgrade?


Solution

  • You'll have to write your "override checking" routine and call it inside the upgrade.php file of your new module version release.

    If you need to clear all cache you can call those core methods :

    Tools::clearSmartyCache();
    Tools::clearXMLCache();
    Media::clearCache();
    

    But this can be very time consuming, depending on the store's cache size.

    If you just need to refresh overrides, I would suggest you to just remove the class_index.php file inside /var/cache/prod.