Prestashop 1.7 无法显示自定义模块

Prestashop 1.7 unable to display custom module

我正在尝试使用 prestashop 1.7,但在创建自定义模块时遇到了问题。 我在 "modules" 文件夹中创建了一个文件夹 "mymodule",并且正如文档中所示,我在其中创建了一个简单的 mymodule.php 文件:

<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

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 = array('min' => '1.6', 'max' => _PS_VERSION_); 
    $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');
  }
}

?>

然后我进入 "modules" 下的管理页面 -> "installed module" 选项卡上的 "modules & services",但我找不到我的模块...

我在做什么错误?

谢谢

泽维尔

你的脚步没问题。 提醒一下,要创建一个 'custom' 模块,我们应该这样做:

  1. 在模块文件夹中创建一个文件夹,例如名为 `mycustommodule`
  2. 创建一个与文件夹同名的 php 文件,例如`mycustommodule.php`
  3. 那么"bootstrap" class(和构造)应该是这样的:
<?php
if (!defined('_PS_VERSION_'))
    exit;

class MyCustomModule extends Module
{
    public function __construct()
    {
        $this->name = 'mycustommodule'; /* This is the 'technic' name, this should equal to filename (mycustommodule.php) and the folder name */
        $this->tab = 'module type category'; /* administration, front_office_features, etc */
        $this->version = '1.0.0'; /* Your module version */
        $this->author = 'Firstname Lastname'; /* I guess it was clear */
        $this->need_instance = 0; /* If your module need an instance without installation */
        $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); /* Your compatibility with prestashop(s) version */
        $this->bootstrap = true; /* Since 1.6 the backoffice implements the twitter bootstrap */

        parent::__construct(); /* I need to explain that? */

        $this->displayName = $this->l('My module'); /* This is the name that merchant see */
        $this->description = $this->l('Description of my module.'); /* A short description of functionality of this module */

        $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); /* This is a popup message before the uninstalling of the module */
    }
}
?>

然后对于 prestashop 1.7.x.x 您必须进入 Modules 并在 Selection 选项卡中单击 'Categories' 并找到您的模块(记住 $this ->标签片段?)

否则你可以通过搜索找到它:

我在 1.7.4 版本上遇到了同样的问题

我通过注释文件中的以下行解决了问题

\src\PrestaShopBundle\Controller\Admin\ModuleController.php

$filters = new AddonListFilter();
 $filters->setType(AddonListFilterType::MODULE | AddonListFilterType::SERVICE);
 //    ->removeStatus(AddonListFilterStatus::UNINSTALLED);
 $installedProducts = $moduleRepository->getFilteredList($filters);

不知道为什么看不到卸载的模块

今天我在Prestashop 1.7.6.1 中遇到了同样的问题。找到问题的 2 个解决方案:

  1. 压缩您的模块并使用 Prestashop 后台上传。例如,如果您使用 git 上传更改则不好。所以我继续搜索,找到了解决方案 2

  2. 如果您创建自定义模块,它会出现在“模块”->“目录”中,而不是“模块”->“模块和服务”选项卡中...非常奇怪且违反直觉的行为。安装此模块后,一切正常。

只需转到模块目录而不是模块管理器,您就会找到您的自定义模块。