我是 Prestashop 模块开发的新手。我正在尝试构建艾米的第一个 prestashop 模块[参考:这是我的代码。我按照该教程中的说明进行了所有操作 https://devdocs.prestashop-project.org/8/modules/creation/tutorial/ 但仍然有问题'无法安装模块我的。该模块无效,无法加载。”环境 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。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
我不知道我是否可以提供帮助,但请尝试检查您的 php 文件是否与“$this->name = 'mymodule';”中的“mymodule”相同