Class 覆盖在 Prestashop 1.7.6 中不再起作用?

Class override doesn't work anymore in Prestashop 1.7.6?

我只需要在类别管理中添加一个名为 'color' 的自定义字段。我在以前的版本中一直使用这种方法,但在 1.7.6 中似乎不再起作用了:

override/classes/Category.php

    /**
     * Class CategoryCore
     */
    class Category extends CategoryCore
    {   
        public $color;    

        public function __construct($id_category = null, $id_lang = null, $id_shop = null){

            self::$definition['fields']['color'] = array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml');

            parent::__construct($id_category, $id_lang, $id_shop);

        }
    }

override/controllers/admin/AdminCategoriesController.php

class AdminCategoriesController extends AdminCategoriesControllerCore
    {
        public function renderForm()
        {
            $this->fields_form_override =array(
                array(
                    'type' => 'text',
                    'label' => $this->trans('Color', array(), 'Admin.Global'),
                    'name' => 'color',
                    'maxlength' => 70,
                    'maxchar' => 70,
                    'lang' => true,
                    'rows' => 5,
                    'cols' => 100,
                    'hint' => $this->trans('Forbidden characters:', array(), 'Admin.Notifications.Info').' <>;=#{}'
                ),
            );

            return parent::renderForm();
        }
    }

最后,我在数据库中添加了一个文本字段 (ps_category_lang) 并删除了所有缓存。

该字段未出现。有人有这个问题吗?我需要使用模块而不是这种方法吗?

谢谢!

您不需要模块。 我试过你的代码,它对我有用 尝试清除后台界面中的缓存以及您将每个文件放在哪里?

同样如此,我不知道为什么它不起作用。我遵循所有的指示。 我使用的是 Prestashop 1.7.6,也许这个过程不适用于最新的 prestashop 版本。因为根据我的阅读,他们使用的是 prestashop v1.6 older.

1.7.6版本好像不再支持这个进程了。我们还需要使用新的 Symfony 模型创建一个模块。

有一个法语源代码解释了如何操作。 Here is the link.

我用自己的代码和新程序创建了一个新的 post。我被困在数据库中的字段保存中。 .