Jump to content

Cannot install module mymodule from tutorial


Recommended Posts

I'm testing the "Creating a Prestashop Module" tutorial for Prestashop 1.5. My version is 1.5.4.1. Link to the tut:

http://doc.prestasho...estaShop+module

 

I think I've done all the steps in it but when I try to load the module I get this error:

  • - mymodule :
    The version of your module is not compliant with your PrestaShop version.

This is the code in mymodule.php, just about the same as in the tutorial:

 

<?php
if (!defined('_PS_VERSION_')) exit;

class MyModule extends Module {
public function __construct()
{
	$this->name = 'mymodule';
	$this->tab = 'front_office_features';
	$this->version = '1.0';
	$this->author = 'Luis Martin';
	$this->need_instance = 0;
	$this->ps_versions_compliancy = array('min' => '1.5', 'max' => '1.5');
	//$this->dependencies = array('blockcart');

	parent::__construct();

	$this->displayName = $this->l('My module');
	$this->description = $this->l('Description of my module.');

	$this->confirmUninstall = $this->l('Are you sure you want to uninstall?');

	if (!Configuration::get('MYMODULE_NAME'))
		$this->warning = $this->l('No name provided');
}

   /**
 * Extra actions on installation
 * @return bool
 */
public function install()
{
	if (Shop::isFeatureActive())
		Shop::setContext(Shop::CONTEXT_ALL);

	return parent::install() &&
		$this->registerHook('leftColumn') &&
		$this->registerHook('header') &&
	Configuration::updateValue('MYMODULE_NAME', 'Hola amigo!');
}

   /**
 * Extra actions on unistallation
 * @return bool
 */
public function uninstall() {
	return parent::uninstall() && Configuration::deleteByName('MYMODULE_NAME');
}
}

 

Am I missing something? :blink:

ps: sorry for the code indentation. This editor is terrible!

Link to comment
Share on other sites

Hi, thanks for your replies.

 

Bellini13: Commenting out that line worked! But the tutorial should be revised, since it says that '1.5' stands for any '1.5.x' subversion:

  • ps_versions_compliancy is new since PrestaShop 1.5. It clearly indicates which version of PrestaShop this module is compatible with. In the example above, we explicitly write that this module will only work with PrestaShop 1.5.x, and no other major version.

 

I was totally convinced that this line should be stated that way to indicate any 1.5.x.x version. I even used '1.5.4.1' as the value for 'max' but didn't work either.

 

Benjamin: the module was in fact listed in the modules list in the backend. Then I clicked on the Install button, and the error message appeared. But it is already solved.

 

Regards!

Link to comment
Share on other sites

I would not rely on this attribute anyway. It does not exist outside of PS v1.5, and would not prevent the module from being used in lower versions of Prestashop, since they are not aware of it.

 

Most developers add their own version checks since it would work on any PS version

Link to comment
Share on other sites

  • 4 months later...

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...