Tomascrespo Posted April 3, 2020 Share Posted April 3, 2020 (edited) Hi, using Prestashop 1.6 I'm developing a module (A) that depends on other module (B). I want to call a function, A::myFunction(), when one object of module B is created. As far as I know, Prestashop ObjectModel use CRUD actions, so... Could I extend the create method of a module B object class? I mean something like: class ModuleAClassModel extends ModuleBClassModel public function create() { myFunction(); parent:create(); } What I really want is to be warned when a module B object is created, to make some actions. Edited April 3, 2020 by Tomascrespo (see edit history) Link to comment Share on other sites More sharing options...
Knowband Plugins Posted April 7, 2020 Share Posted April 7, 2020 Just create a constructor function in the B class & throw the error in the constructor function. & Override the constructor function in the class A (Which extends the Class B). So if anyone will create the direct object of the B class, System will get the error. We hope, It will solve your problem. Link to comment Share on other sites More sharing options...
fbenoist.com Posted April 8, 2020 Share Posted April 8, 2020 (edited) You can use the actionObject{ObjectName}AddAfter , actionObject{ObjectName}UpdateAfter, actionObject{ObjectName}DeleteAfter hooks. Replace {ObjectName} with the class name of the Object. For example: actionObjectModuleBClassModelAddAfter Edited April 8, 2020 by fbenoist.com (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now