El Patron Posted March 30, 2012 Share Posted March 30, 2012 For some reason I can not get error messages to display for my install/uninstall/enable/disable functions. I tried two different ways I found to display error messages. During test I force the error to occur but get no messages from the module manager. Does anyone know a standard method for modules to pass error/warnings back to the module manager? Thanks in advance for your review. <?php class myModule extends Module { private $_html = ''; /** * Constructor */ function __construct() { $this->name = 'mymodule'; $this->tab = 'tabname'; $this->version = 'version'; $this->author = 'author name'; parent::__construct(); $this->displayName = $this->l('module display name'); $this->description = $this->l('module description'); $this->need_instance = 1; $this->_errors = array(); } public function install(){ if(version_compare(_PS_VERSION_, '1.4', '<')){ return Tools::displayError('Module only supports PrestaShop Version(s) 1.4.x'); } if (!parent::install()) return false; if( !$this->createBackUp()){ return Tools::displayError('Install: failed creating backup - /config/config.inc.php'); } if( !$this->enable()){ return Tools::displayError('Install: failed installing backup - /config/config.inc.php'); } return Module::enableByName($this->name); } // public function enable() { if (!parent::enable()) return false; if( !$this->installConfigOverride()){ $this->_errors[] = $this->l('Enable: failed installing - something something'); $error_msg = ''; foreach ($this->_errors AS $error) $error_msg .= $error.'<br />'; $this->_html = $this->displayError($error_msg); return false; } return Module::enableByName($this->name); } } ?> Link to comment Share on other sites More sharing options...
Terragg Posted January 17, 2013 Share Posted January 17, 2013 The issue tracker for Module->errors is ignored indicates that writing directly to the controller is a workaround: Also, you can write the errors directly on the controller if you want : $this->context->controller->errors[] = 'give an error regardless'; I can verify that it works for v1.5.2. 1 Link to comment Share on other sites More sharing options...
El Patron Posted January 18, 2013 Author Share Posted January 18, 2013 Thanks for your feedback... I've grown since my original post...I will need to post these leanings here in the near future. 1.5 is starting to grow on me... Link to comment Share on other sites More sharing options...
Terragg Posted January 18, 2013 Share Posted January 18, 2013 You're welcome. Nine months and several non-trivial PrestaShop updates later, I figured you probably had come up with a workaround and had forgotten about this. I found this thread near the top of the list when I googled "displaying errors during install" (or something similar). My post was mainly an FYI for future searchers. 1.5 is my first PrestaShop, so I'm still coming up to speed on the platform's internals. Big change from osCommerce 2.x ! 1 Link to comment Share on other sites More sharing options...
Esnyper Posted December 17, 2014 Share Posted December 17, 2014 How about 1.6? Terragg solution not working. Link to comment Share on other sites More sharing options...
jave.web Posted September 4, 2015 Share Posted September 4, 2015 (edited) Edit: I had a silly mistake in condition (forgot to put ! inside a condition:) public function install() { if (Shop::isFeatureActive()) Shop::setContext(Shop::CONTEXT_ALL); if ( ! parent::install() || ! $this->registerHook('DisplayHook') || ! Configuration::updateValue($this->name, "installed") ) //forgot "!" before this one ! return false; return true; } I did a plugin according to the tutorial "Creating a first module" ( http://doc.prestashop.com/display/PS16/Creating+a+first+module#Creatingafirstmodule-FilestructureforaPrestaShopmodule ) And I even skipped a few things and it works, Edited September 4, 2015 by jave.web (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