hakeryk2 Posted March 24, 2017 Share Posted March 24, 2017 Hello, I have question. I wrote an function which I like in module A. Right now I am developing module B and I would love to use this function from A in B without copying it. Any Idea how to achieve this? Link to comment Share on other sites More sharing options...
joseantgv Posted March 24, 2017 Share Posted March 24, 2017 Hello, I have question. I wrote an function which I like in module A. Right now I am developing module B and I would love to use this function from A in B without copying it. Any Idea how to achieve this? Instantiate the class (the module class) and call your function: $module = new YourModule(); $module->function(); 1 Link to comment Share on other sites More sharing options...
hakeryk2 Posted March 24, 2017 Author Share Posted March 24, 2017 (edited) I tried with $module = new Cwarehouse(); but after that I am getting Class 'Cwarehouse' not found in Mylocalhostaddress\modules\checkavailability\checkavailability.php on line 332 this is proper name of my class because in this module I used class Cwarehouse extends Module { } This is funny because even my IDE is getting functions from this class when I use $module->getImagePath();Any help? -------------------------------------------------------------------------------------- EDIT with solution: I just added on the beggining and everythings works now. Thank You for Your help. include '../modules/cwarehouse/cwarehouse.php'; Edited March 24, 2017 by hakeryk2 (see edit history) 1 Link to comment Share on other sites More sharing options...
destunk Posted December 28, 2018 Share Posted December 28, 2018 On 3/24/2017 at 2:38 PM, hakeryk2 said: EDIT with solution: I just added on the beggining and everythings works now. Thank You for Your help. include '../modules/cwarehouse/cwarehouse.php'; To avoid any path errors, you should call this instead : include_once _PS_MODULE_DIR_ . 'MODULENAME/MODULENAME.php'; 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