如何在“管理产品”页面中添加自定义输入字段

时间:2019-01-31 11:12:34

标签: prestashop prestashop-1.7

如何使用钩子在“产品图像”表单中添加自定义输入字段。我试图在“产品图像”表单中添加新复选框,但我不知道如何使用模块创建它,也无法覆盖核心产品页面template.I我createing内themes目录结构/经典/模块/ MODULE_NAME /.....

如果有的可写的Prestashop 1.7的主模块PHP文件,我非常感谢你。

1 个答案:

答案 0 :(得分:0)

<?php

if (!defined('_PS_VERSION_')) {
    exit;
}

class youmodule extends Module
{
    protected $config_form = false;

    public function __construct()
    {
        $this->name = 'youmodule';
        $this->tab = 'administration';
        $this->version = '1.0.0';
        $this->need_instance = 0;
        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = $this->l('youmodule');
        $this->description = $this->l('youmodule');

        $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
    }

    public function install()
    {
        return parent::install() &&
            $this->registerHook('header') &&
            $this->registerHook('displayAdminProductsExtra');
    }

    public function uninstall()
    {
        return parent::uninstall();
    }


    public function hookDisplayAdminProductsExtra($params)
    {
        $id_product = Tools::getValue('id_product');

        //YOURCODE

        $this->smarty->assign(array(
            'yourvariable' => $yourvariabl
        ));
        return $this->display(__FILE__, '/views/templates/admin/product.tpl');
    }
}