Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 产品功能的预设模块_Php_Prestashop_Prestashop 1.7 - Fatal编程技术网

Php 产品功能的预设模块

Php 产品功能的预设模块,php,prestashop,prestashop-1.7,Php,Prestashop,Prestashop 1.7,我正在做一个prestashop定制模块。 此模块必须显示一些产品功能,让管理员修改其值,然后将其保存在自定义选项卡中 因此,在自定义选项卡中显示功能并不困难: public function hookDisplayAdminProductsExtra($params) { $id_lang = $this->context->language->id; $features = FeatureCore::getFeatures($id_lang); $

我正在做一个prestashop定制模块。 此模块必须显示一些产品功能,让管理员修改其值,然后将其保存在自定义选项卡中

因此,在自定义选项卡中显示功能并不困难:

public function hookDisplayAdminProductsExtra($params) {

    $id_lang = $this->context->language->id;
    $features = FeatureCore::getFeatures($id_lang);
    $values = [];
    foreach ($features as $feature) {
      array_push($values, $feature['value']);
    }

    $this->context->smarty->assign(array(
        'features' => $features,
        'values' => $values
    ));

    if(!empty($sampleObj) && isset($sampleObj->id)){
        $this->context->smarty->assign(array(
            'custom_text_area' => $sampleObj->textarea
        ));
    }

    return $this->display(__FILE__, 'views/admin/sample.tpl');
}
我唯一得不到的是特性的默认值,以便将它们放入select

在那之后,我想做的是能够保存产品保存的每一个价值

所以我写了这个钩子:

public function hookActionProductUpdate($params) {
    $id_product = $params['id_product'];
    $product = new Product($id_product);
    var_dump($product);
    $all_tpl_vars = $smarty->getTemplateVars();
    print_r($all_tpl_vars);        
    die("hello");
}
但当我按下保存按钮时,什么也不会发生,屏幕上也不会显示任何内容

这是我的第一个prestashop模块,所有挂钩都已在模块构造函数中注册


谢谢大家。

您使用的是什么版本的prestashop?我使用的是1.7版