2017-02-06 5 views
2

Почему prestashop не сохраняет мою модификацию в базе данных? Я сделал переопределение на category.php (Prestashop 1.7) файл класса, вот мой код:Переопределение не работает на prestashop 1.7 Класс категории

/override/classes/Category.php

класс Категория распространяется CategoryCore { /** * afficher/masquer les produits */ public $ show_products = 1; public $ andrana;

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

}

/override\controllers\admin\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: Я добавил "show_products" на ps _category стол и "andrana" в ps_category_lang таблице

Пожалуйста, помогите мне :(

ответ

2

изменить __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); 
} 
Смежные вопросы