Php Prestashop 1.7无法显示自定义模块

Php Prestashop 1.7无法显示自定义模块,php,prestashop,prestashop-1.7,Php,Prestashop,Prestashop 1.7,我正在尝试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 | T

我正在尝试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');
  }
}

?>

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

我犯了什么错误

谢谢

Xavier

你的步子很好。 要进行提醒,要创建“自定义”模块,我们应执行以下操作:

  • 在模块文件夹中创建一个文件夹,例如名为“mycustommodule”`
  • 创建一个名为类似文件夹的php文件,例如`mycustommodule.php`
  • 那么“引导”类(和构造)应该是这样的:
  • 
    
    然后,对于prestashop 1.7.x.x,您必须进入
    模块
    ,并在
    选择
    选项卡中单击“类别”并找到您的模块(还记得$this->tab片段吗?)

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


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

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

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


    我不知道为什么我们看不到卸载的模块今天我在Prestashop 1.7.6.1中遇到了同样的问题。找到了问题的两种解决方案:

  • 压缩您的模块并使用Prestashop backoffice上传。例如,如果您使用git上载更改,则不太好。所以我继续搜索,找到了第二个解决方案

  • 如果创建自定义模块,它将显示在模块->目录而不是模块->模块和服务选项卡中。。。非常奇怪和违反直觉的行为。安装此模块后,一切正常


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

    如果尚未安装该模块,它将不会显示在“已安装模块”选项卡中。您应该在第一个选项卡中查找它。另外,别忘了添加安装和卸载功能。进入选择选项卡,而不是安装modules@Konrad我认为它没有太大的变化,您是否遵循了这些步骤?这是Prestashop 1.7.x的唯一正确答案,在1.6 backoffice中是完全不同的。
    <?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 */
        }
    }
    ?>
    
    $filters = new AddonListFilter();
     $filters->setType(AddonListFilterType::MODULE | AddonListFilterType::SERVICE);
     //    ->removeStatus(AddonListFilterStatus::UNINSTALLED);
     $installedProducts = $moduleRepository->getFilteredList($filters);