marcis Posted March 29, 2013 Share Posted March 29, 2013 I've been doing some tests and it doesn't happen, shouldn't it behave this way? Link to comment Share on other sites More sharing options...
Burhan BVK Posted March 29, 2013 Share Posted March 29, 2013 Edit classes/module/Module.php. Find "public function disable($forceAll = false)", add the following to the end of the function: $this->uninstallOverrides(); Find "public function enable($forceAll = false)", add the following before the "return true": $this->installOverrides(); Now the overrides are disabled when the module is disabled. 1 Link to comment Share on other sites More sharing options...
marcis Posted March 29, 2013 Author Share Posted March 29, 2013 Ok, thanks! But this should be the default behaviour, right? Link to comment Share on other sites More sharing options...
El Patron Posted March 29, 2013 Share Posted March 29, 2013 (edited) You may not want to remove your class overried on a disable. This is because of MultiShop, if the module is disabled on one shop but enabled on other shops then you don't want to remove the override. enable/disable in my module with parms public function enable/disable ($forceAll = false) then in my class override I check the module is enabled if (Module::isEnabled('my_module_name') you may consider developing with error E_ALL or at least E_STIRCT, this would tell you that you are missing $forceAll = false Note: the above code runs in 1.4 and 1.5 Edited March 29, 2013 by elpatron (see edit history) 1 Link to comment Share on other sites More sharing options...
marcis Posted March 29, 2013 Author Share Posted March 29, 2013 Nice solution, thanks! But I'd prefer to disable the module for one shop (undoing the override) and not for the others. I guess it's complicated, but Prestashop guys can do it! Link to comment Share on other sites More sharing options...
El Patron Posted March 29, 2013 Share Posted March 29, 2013 (edited) another piece of advice...avoid overrides at all costs...if you can use a hook, then all is taken care of for you by ps. I used to be a big override fan until I found out how complicated it is to manage them...i.e. if override exists etc.... and if you run with E_STIRCT you would have found out about he enable/disable parms suerte Edited March 29, 2013 by elpatron (see edit history) 1 Link to comment Share on other sites More sharing options...
marcis Posted March 30, 2013 Author Share Posted March 30, 2013 Instead of overriding the controller itself you are suggesting me to use a hook? So... if I want to modify the contact form, I guess I can use the displayHome hook and then... checking the name of the page? What else will I need? A new customized controller? How can I prevent the default contact form from showing? Thank you! Link to comment Share on other sites More sharing options...
karthik@it-connects. Posted November 14, 2013 Share Posted November 14, 2013 You may not want to remove your class overried on a disable. This is because of MultiShop, if the module is disabled on one shop but enabled on other shops then you don't want to remove the override. enable/disable in my module with parms public function enable/disable ($forceAll = false) then in my class override I check the module is enabled if (Module::isEnabled('my_module_name') you may consider developing with error E_ALL or at least E_STIRCT, this would tell you that you are missing $forceAll = falseNote: the above code runs in 1.4 and 1.5 i got some modules that over rides the other. since these modules belong to different themes and all themes are used by different shop. hence i don't want to disable any of the modules. Can i have a suggestion so that the modules doesn't override. Link to comment Share on other sites More sharing options...
ben mbarek afef Posted December 12, 2013 Share Posted December 12, 2013 Hello, I'd prefer to disable the module for one shop (undoing the override) and not for the others.have you a solution please? Link to comment Share on other sites More sharing options...
El Patron Posted December 12, 2013 Share Posted December 12, 2013 Hello, I'd prefer to disable the module for one shop (undoing the override) and not for the others.have you a solution please? the way I handle this, for multistore and also in 1.4, is check in the override if the module is enabled. This would seem a sensible approach. in class override if (Module::isEnabled('your_module_name') Link to comment Share on other sites More sharing options...
ben mbarek afef Posted December 12, 2013 Share Posted December 12, 2013 (edited) where i'd put this instruction sir? for example in myself I override ordercontroller by deleting some instruction, I put this statement in this class or where .. I did not understand Edited December 12, 2013 by ben mbarek afef (see edit history) Link to comment Share on other sites More sharing options...
El Patron Posted December 12, 2013 Share Posted December 12, 2013 the code would be part of your override logic, so at the top if module is enabled execute your override logic else do something else, return,execute parent class...etc Link to comment Share on other sites More sharing options...
ben mbarek afef Posted December 12, 2013 Share Posted December 12, 2013 thank you Sir but where i can find the file.php responsible for the execution of all override in prestashop? In my module in put this change: public function install() {...... // Install overrides try { if (Module::isEnabled('mymodule'){ $this->installOverrides();} } catch (Exception $e) { $this->_errors[] = sprintf(Tools::displayError('Unable to install override: %s'), $e->getMessage()); $this->uninstallOverrides(); return false; } .........} it's this that you mean ? Link to comment Share on other sites More sharing options...
El Patron Posted December 12, 2013 Share Posted December 12, 2013 thank you Sir but where i can find the file.php responsible for the execution of all override in prestashop? In my module in put this change: public function install() {...... // Install overrides try { if (Module::isEnabled('mymodule'){ $this->installOverrides();} } catch (Exception $e) { $this->_errors[] = sprintf(Tools::displayError('Unable to install override: %s'), $e->getMessage()); $this->uninstallOverrides(); return false; } .........} it's this that you mean ? this is coding for 1.4 yes? for 1.5 you overrides when placed in proper module folder will be 'automatically' installed in the override directory. So you only need to install them programatically in 1.4 this might help http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module note you should use hooks whenever possible (PrestaShop has just started rejecting modules for offical addon's that use overrides). Link to comment Share on other sites More sharing options...
ben mbarek afef Posted December 12, 2013 Share Posted December 12, 2013 No , it's coding for 1.5 , In my module i created a folder "override" when i installed my module the override exucting automatically ,here is the code responsible in the function install() of module // Install overrides try { $this->installOverrides(); } catch (Exception $e) { $this->_errors[] = sprintf(Tools::displayError('Unable to install override: %s'), $e->getMessage()); $this->uninstallOverrides(); return false; } Now i made this change public function install() {...... // Install overrides try { if (Module::isEnabled('mymodule'){ $this->installOverrides();} } catch (Exception $e) { $this->_errors[] = sprintf(Tools::displayError('Unable to install override: %s'), $e->getMessage()); $this->uninstallOverrides(); return false; } .........} it's Ok Sir? ... Link to comment Share on other sites More sharing options...
El Patron Posted December 12, 2013 Share Posted December 12, 2013 in 1.5...the ovrerride will exist in the override folder...until the module is uninstalled. It is then remove by PrestaShop if you want a module, after installation to work in multistore...i.e. enabled in some shop(s), and disabled in other shop(s). then simply add the this code at INTO your class override. if (Module::isEnabled('your_module_name') this way if the override is called but the module is not enabled 'for this shop context', you can take appropriate action. Note: a module when is disabled for that current shop, will never get control. Link to comment Share on other sites More sharing options...
ben mbarek afef Posted December 12, 2013 Share Posted December 12, 2013 Thank you very much Sir it's solved. 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