2

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

/覆盖/类/Category.php

class Category extends CategoryCore { /** * afficher/masquer les produits */ public $show_products = 1; 公共$andana;

public function __construct($idCategory = null, $idLang = null, $idShop = null)
{
    $definition = self::$definition;

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

}

/覆盖\控制器\管理员\AdminCategoriesController.php

类 AdminCategoriesController 扩展 AdminCategoriesControllerCore {

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();
}

}

PS:我在 ps_category 表中添加了“show_products”,在 ps_category_lang 表中添加了“andana”

请帮我 :(

4

1 回答 1

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);
}
于 2017-02-06T19:18:40.447 回答