Jump to content

standard method for modules to pass error/warnings back to the module manager?

PrestaHeroes USA

Recommended Posts

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.


class myModule extends Module
private $_html = '';
* Constructor
function __construct()
 $this->name = 'mymodule';
 $this->tab = 'tabname';  
 $this->version = 'version';
 $this->author = 'author name';

 $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

  • 9 months later...

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 !

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
  • 8 months later...

Edit: I had a silly mistake in condition (forgot to put ! inside a condition:)


public function install() {
    if (Shop::isFeatureActive())
    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 by jave.web (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...