Jump to content

Override function from a module, across different PS versions


cristic

Recommended Posts

I have a question a little bit advanced in regards to function override for a core class from a module.

 

Standard way is to place the override in /modules/my_module/override/classes/XXX.php and PS install() function will handle all the rest.

 

But what if the function that is being overridden has different parameters between PS versions? This will require different override files and a way to use the correct one upon install. But is there a way to accomplish this automatically?

 

One way that I was thinking is to leave the folder /modules/my_module/override/classes/ empty and on install function, before calling parent::install() - first to copy the correct file based on the actual PS version, where the module is installed.

 

Is there another way to do this?

Link to comment
Share on other sites

I have a question a little bit advanced in regards to function override for a core class from a module.

 

Standard way is to place the override in /modules/my_module/override/classes/XXX.php and PS install() function will handle all the rest.

 

But what if the function that is being overridden has different parameters between PS versions? This will require different override files and a way to use the correct one upon install. But is there a way to accomplish this automatically?

 

One way that I was thinking is to leave the folder /modules/my_module/override/classes/ empty and on install function, before calling parent::install() - first to copy the correct file based on the actual PS version, where the module is installed.

 

Is there another way to do this?

 

I think that this is a smart way of doing it. 

  • Like 1
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...