繁体   English   中英

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');
  }
}

?>

然后我进入“模块”->“模块和服务”下的“已安装模块”选项卡下的管理页面,但我找不到我的模块...

我在做什么错误?

谢谢

泽维尔

你的步骤没问题。 提醒一下,要创建一个“自定义”模块,我们应该这样做:

  1. 在模块文件夹中创建一个文件夹,例如命名为`mycustommodule`
  2. 创建一个命名为文件夹的php文件,例如`mycustommodule.php`
  3. 那么“引导”类(和构造)应该是这样的:
<?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.xx,您必须进入Modules并在Selection选项卡中单击“类别”并找到您的模块(还记得 $this->tab 片段吗?)

类别菜单

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

搜索输入

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

  1. 压缩您的模块并使用 Prestashop 后台上传。 例如,如果您使用 git 上传更改,那就不好了。 所以我一直在寻找,并找到了解决方案 2

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

我在 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);

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM