Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update class override when upgrading module to new version in Prestashop?

Let's say there is a module with version 0.1.

This module already have overrides applied for example to classes/Cart.php.

New requirement comes in and we make a change to an already overridden classes/Cart.php.

To apply new change we update module version to 0.2, but after update Prestashop doesn't reapply new overrides. I also tried placing upgrade script in upgrade folder which I confirmed was executing but old override is still there.

How do you apply new overrides without reinstalling the module?

like image 737
Aleksandar Janković Avatar asked Oct 15 '25 04:10

Aleksandar Janković


1 Answers

In the upgrade method you could run in sequence uninstallOverrides and installOverrides, it would result in installing the state of your overrides at your current version.

File upgrade/upgrade-1.1.0.php:

function upgrade_module_1_1_0($module)
{
    $module->uninstallOverrides();
    $module->installOverrides();
    return true;
}
like image 54
mcdado Avatar answered Oct 18 '25 01:10

mcdado



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!