gr4devel Posted July 22, 2013 Share Posted July 22, 2013 (edited) Hi community, today my problem is concerning an override. I need to override a controller and call in the override a method of the module that overrides the controller. If I try to include the php file with include_once('.'._MODULE_DIR_.'mymodule/mymodule.php'); I get an error on the staging server when I try to install the module (PS simply doesn't find the module while copying the override in the root override directory). If I try with include_once(_MODULE_DIR_.'mymodule/mymodule.php'); I get an error when the override is called. To conclude if I try to remove the inclusion of the file I get Fatal error: Class 'MyModule' not found in /path/to/controller What should I do? P.S: I need to instatiate the module because I need to call one of its method that rely on one of its property... Edited August 29, 2013 by gr4devel (see edit history) Link to comment Share on other sites More sharing options...
spm.presto Posted July 22, 2013 Share Posted July 22, 2013 Hi Use DIRECTORY_SEPARATOR for include files Maybe this will help Regards Link to comment Share on other sites More sharing options...
gr4devel Posted July 23, 2013 Author Share Posted July 23, 2013 Ok I solved it by moving the include_once inside the init method of the controller and by modifying the path in this way: include_once(dirname(__FILE__).'/../../../modules/daneainvoiceimporter/daneainvoiceimporter.php'); Please if anyone has a better way to handle this situation write it down here...I really feel that what I've done is a bad thing P.S: I'll leave the topic open till news... Link to comment Share on other sites More sharing options...
gr4devel Posted August 29, 2013 Author Share Posted August 29, 2013 I close the topic but I invite everyone that has a better solution than mine to write it down here 1 Link to comment Share on other sites More sharing options...
eVoShoP Posted April 10, 2014 Share Posted April 10, 2014 Hi, an easier solution : include(_PS_MODULE_DIR_.'mymodule'.DIRECTORY_SEPARATOR.'mymodule.php'); note : If you're sure to call mymodule.php just one time, prefer include to include_once (a little more greedy because check if already called). Link to comment Share on other sites More sharing options...
savedario Posted November 14, 2016 Share Posted November 14, 2016 On Prestashop 1.6.1.6 I've managed with: $myModule = Module::getInstanceByName('mymodule'); 1 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