Jump to content

Custom module wont install on hosted server. Installs on localhost.


Recommended Posts

I am getting this error message when trying to install custom module "WineRegion".

 

You do not have the rights to update the wineregion module. Please make sure you are logged in to the PrestaShop Addons account that purchased the module.

 

The module installs and works on localhost using WAMP on Windows 10. However, on the hosted server it won't install.

 

Any help would be appreciated!

 

This is the constructor:

 

 

if (!defined('_PS_VERSION_')) exit;
 
class WineRegion extends Module {
 
    public function __construct() {
        $this->name = 'wineregion';
        $this->tab = 'others';
        $this->version = '1.0';
        $this->author = 'Wineo';
        $this->need_instance = 0;
 
        parent::__construct();
 
        $this->displayName = $this->l('Wine Regions');
        $this->description = $this->l('Main Regions in Bulgaria');
    }
 
    public function install() {
 
$tab = new Tab();
foreach (Language::getLanguages() as $language)  {
$tab->name[$language['id_lang']] = $this->l('Wine Regions');
}
$tab->class_name = 'AdminRegion';
$tab->id_parent = 0;
$tab->module = $this->name;
$tab->add();
 
        if (!parent::install()
OR !$this->registerHook('displayBackOfficeHeader')
OR !$this->createTables()) {
            return false;
        }
        return true;
    }
 
    public function uninstall() {
$tab = new Tab((int)Tab::getIdFromClassName('AdminRegion'));
$tab->delete();
        if (!parent::uninstall() OR !$this->deleteTables()) {
            return false;
        }
        return true;
    }
 
protected function createTables()
{
$res = (bool)Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'wineregion` (
 `id_wineregion` int(2) NOT NULL AUTO_INCREMENT,
 `latitude` float DEFAULT NULL,
 `longitude` float DEFAULT NULL,
        `image` varchar(255) DEFAULT NULL,
 PRIMARY KEY (`id_wineregion`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
');
 
$res &= Db::getInstance()->execute('
CREATE TABLE `'._DB_PREFIX_.'wineregion_lang` (
 `id_wineregion` int(2) UNSIGNED NOT NULL,
 `id_lang` int(2) UNSIGNED NOT NULL,
 `region_name` varchar(50) DEFAULT NULL,
 `region_description` text DEFAULT NULL,
 `region_tradition` text DEFAULT NULL,
 `food_tradition` text DEFAULT NULL,
 `region_wine_sorts` text DEFAULT NULL,
 PRIMARY KEY (`id_wineregion`,`id_lang`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
');
 
return $res;
}
 
protected function deleteTables()
{
return Db::getInstance()->execute('
DROP TABLE IF EXISTS `'._DB_PREFIX_.'wineregion`, `'._DB_PREFIX_.'wineregion_lang`;
');
}
 
public function hookDisplayBackOfficeHeader($params) {
$this->context->controller->addCSS($this->_path . 'css/region.css');
    }
}
 

 

 

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