【问题标题】:Prestashop create two modules in one installationPrestashop 在一次安装中创建两个模块
【发布时间】:2016-08-25 11:59:37
【问题描述】:

在我的模块中,我需要扩展 prestashop 核心 CarrierModulePaymentModule,因为它具有运输和支付部分。所以我打算单独创建两个不同的模块并将它们构建在一个文件夹中并安装一次。 我需要知道如何制作安装脚本来安装两个模块(一个接一个)。

这是一个模块的安装功能

public function install() {
        $flag = parent::install();
        if ($this->name !== 'urbitbasic')
            $flag = ($flag && $this->registerHook('displayRightColumnProduct'));

        return ($this->installer->installTables() &&
                $this->installer->installCarriers() &&
                $this->installer->installWarehouseCarriers() &&
                $this->installTabs() &&
                $this->registerHook('displayBackOfficeHeader') &&
                $this->registerHook('actionCarrierUpdate') &&
                $this->registerHook('actionObjectCarrierUpdateAfter') &&
                $this->registerHook('displayCarrierList') &&
                $this->registerHook('displayOrderConfirmation') &&
                $flag);
    }

基本上我需要创建一个模块,一个安装文件安装两个模块。

【问题讨论】:

  • 一个文件夹中的两个模块??
  • @sarcom 我的意思是我有两个模块需要一起安装
  • 抱歉,我了解到您在一个文件夹中有两个模块 build them in one folder :)。

标签: php prestashop prestashop-1.5


【解决方案1】:

你必须安装几乎一个模块,选择你哪一个,在那个模块中你可以做这个过程:

public function install() {
    $flag = parent::install();
    if ($this->name !== 'urbitbasic')
        $flag = ($flag && $this->registerHook('displayRightColumnProduct'));

    $first_install = ($this->installer->installTables() &&
            $this->installer->installCarriers() &&
            $this->installer->installWarehouseCarriers() &&
            $this->installTabs() &&
            $this->registerHook('displayBackOfficeHeader') &&
            $this->registerHook('actionCarrierUpdate') &&
            $this->registerHook('actionObjectCarrierUpdateAfter') &&
            $this->registerHook('displayCarrierList') &&
            $this->registerHook('displayOrderConfirmation') &&
            $flag);
    // Now we install the second module
    $mysecondmodule = Module::getInstanceByName('{thenameofyoursecondmodule}');
    $second_install = $mysecondmodule->install();

    return $first_install AND $second_install;
}

【讨论】:

  • @rcom 我可以创建两个不同的安装程序文件吗?因为我需要extendPaymentModuleCarrierModule。那么如何根据您的回答创建第二个模块?
  • 如果你创建了两个模块,你必须有两个不同的文件,例如:urbitbasic/urbitbasic.phpurbitplus/urbitplus.php你不能在同一个文件夹中有两个模块,这是 PrestaShop MVC 规则。要回答您的问题,是的,不可以,您必须创建第二个模块:)
  • 感谢您的建议。当我创建两个不同的文件和两个模块时,我可以创建一个通用文件来一次安装两个模块吗?因为用户应该安装一个。
  • 也许我不是很清楚,在您安装第二个模块的两个模块之一中,这两个模块必须“独立”工作,您想要做的只是对用户的简化/商人 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-12-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多