覆盖不在prestashop 1.7类别类上工作

时间:2017-02-06 09:40:31

标签: override prestashop-1.7

为什么prestashop不会将我的修改保存到数据库中? 我已经对Category.php(prestashop 1.7)类文件进行了覆盖,这是我的代码:

/override/classes/Category.php

类类别扩展了CategoryCore {     / **     * afficher / masquer les produits     * /     public $ show_products = 1;     public $ andrana;

public function renderForm()
{
    $this->fields_form_override = array(
        array(
            'type' => 'switch',
            'label' => $this->trans('Afficher les produits', array(), 'Admin.Global'),
            'name' => 'show_products',
            'required' => false,
            'is_bool' => true,
            'values' => array(
                array(
                    'id' => 'active_on',
                    'value' => 1,
                    'label' => $this->trans('Enabled', array(), 'Admin.Global')
                ),
                array(
                    'id' => 'active_off',
                    'value' => 0,
                    'label' => $this->trans('Disabled', array(), 'Admin.Global')
                )
            )
        ),
        array(
            'type' => 'textarea',
            'label' => $this->trans('Andrana', array(), 'Admin.Global'),
            'name' => 'andrana',
            'autoload_rte' => true,
            'lang' => true,
            'hint' => $this->trans('Invalid characters:', array(), 'Admin.Notifications.Info').' <>;=#{}'
        ),
    );
    return parent::renderForm();
}

}

/override\controllers\admin\AdminCategoriesController.php

类AdminCategoriesController扩展了AdminCategoriesControllerCore {

{{1}}

}

PS:我已添加&#34; show_products&#34;在ps_category表和&#34; andrana&#34;在ps_category_lang表中

请帮帮我:(

1 个答案:

答案 0 :(得分:3)

将__construct更改为:

public function __construct($idCategory = null, $idLang = null, $idShop = null)
{

    self::$definition['fields']['show_products'] = array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true);
    self::$definition['fields']['andrana'] = array(
        'type' => self::TYPE_HTML,
        'lang' => true,
        'validate' => 'isCleanHtml'
    );
    parent::__construct($idCategory, $idLang, $idShop);
}