英文:
Cannot install custom module in prestashop
问题
我是新手Prestashop模块开发者。我正在尝试构建我的第一个Prestashop模块[参考:这是我的代码。我按照教程https://devdocs.prestashop-project.org/8/modules/creation/tutorial/中的说明做了一切,但仍然遇到问题:“无法安装模块My。模块无效,无法加载。” PHP环境:7.4,Prestahop:8.1.0
<?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.0';
$this->author = 'Firstname Lastname';
$this->need_instance = 0;
$this->ps_versions_compliancy = [
'min' => '1.7.0.0',
'max' => '8.99.99',
];
$this->bootstrap = true;
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');
}
}
public function install()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
return (
parent::install()
&& Configuration::updateValue('MYMODULE_NAME', 'my module')
);
}
public function uninstall()
{
return (
parent::uninstall()
&& Configuration::deleteByName('MYMODULE_NAME')
);
}
}
我按照教程中的说明做了一切。我本来希望它会安装我的自定义模块到Prestashop。
英文:
I am new in Prestashop module development. I am trying to build amy first prestashop module[ref: Here is my code.I did everything as in that tutorial writes https://devdocs.prestashop-project.org/8/modules/creation/tutorial/ and still have a problem 'Cannot Install module My. The module is invalid and cannot be loaded.' Enviroment PHP:7.4, Prestahop : 8.1.0
<?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.0';
$this->author = 'Firstname Lastname';
$this->need_instance = 0;
$this->ps_versions_compliancy = [
'min' => '1.7.0.0',
'max' => '8.99.99',
];
$this->bootstrap = true;
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');
}
}
public function install()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
return (
parent::install()
&& Configuration::updateValue('MYMODULE_NAME', 'my module')
);
}
public function uninstall()
{
return (
parent::uninstall()
&& Configuration::deleteByName('MYMODULE_NAME')
);
}
}
I did everything what as in tutorial writes. I did expect that it installed my custom module to prestashop.
答案1
得分: 1
我不知道是否能提供帮助,但请尝试检查您的PHP文件是否与“mymodule”在“$this->name = 'mymodule';”中相同。
英文:
I don't know if I can be of help but try to check if your php file is the same as the "mymodule" in "$this->name = 'mymodule'; "
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论