Prestashop 1.7 Hook 管理产品不显示

Prestashop 1.7 Hook admin product does not display

我在 Prestashop 上有一个适用于版本 1.6 和 1.7 的模块。

在 1.6 版中,我设法在 bacok 办公室的产品 sheet 上显示了一个附加字段。我想对 1.7 版做同样的事情,但目前没有成功...

我尝试使用 displayAdminProductsMainStepLeftColumnMiddle 挂钩

我的模块控制器:

public function displayAdminProductsMainStepLeftColumnMiddle($params) {
    $product = new Product($params['id_product']);

    $this->context->smarty->assign(array(
        'id_product_jshop' => $product->id_product_jshop
        )
    );

    return $this->display(__FILE__, '/views/templates/1.7/admin/jshop.tpl');

hook的录音

$this->registerHook('displayAdminProductsMainStepLeftColumnMiddle');

我的观点:

<div class="m-b-1 m-t-1">
<h2>{l s='Custom Attribute from module' mod='jshopimport'}</h2>

<fieldset class="form-group">
<div class="col-lg-12 col-xl-4">

<label class="form-control-label">{l s='ID JSHOP' mod='jshopimport'}</label>
<input type="text" name="id_product_jshop" class="form-control" {if $id_product_jshop && $id_product_jshop != ''}value="{$id_product_jshop}"{/if}/>

</div>
</fieldset>

<div class="clearfix"></div>
</div>

你知道哪里出了问题吗?

函数必须以 "hook" 和

开头
public function hookDisplayAdminProductsMainStepLeftColumnMiddle($params)

然后你不挂钩就注册了

$this->registerHook('displayAdminProductsMainStepLeftColumnMiddle');

供参考,我发现了我的错误。

在我完成安装之前:

$this->registerHook('displayAdminProductsMainStepLeftColumnMiddle'));

return parent::install();

使用此解决方案,挂钩未注册!!

最佳实践是:

if (!parent::install()
        || !$this->registerHook('displayAdminProductsExtra')
        || !$this->registerHook('displayAdminProductsMainStepLeftColumnMiddle')) {
            return false;
    }

先做很重要

parent::install()