herwaldi Posted December 17, 2019 Share Posted December 17, 2019 I have a problem adding a custom field in the category - Prestashop 1.7.6 I do override for override/classes/Category.php <?php class Category extends CategoryCore { public $headingh1; public function __construct($idCategory = null, $idLang = null, $idShop = null) { $definition = self::$definition; $definition['fields']['headingh1'] = array( 'type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml' ); parent::__construct($idCategory, $idLang, $idShop); } } Then I do override for override/controllers/admin/AdminCategoriesController.php <?php class AdminCategoriesController extends AdminCategoriesControllerCore { public function renderForm() { $this->fields_form_override = array( array( 'type' => 'textarea', 'label' => $this->trans('Nagłówek H1', array(), 'Admin.Global'), 'name' => 'headingh1', 'autoload_rte' => true, 'lang' => true, 'hint' => $this->trans('Invalid characters:', array(), 'Admin.Notifications.Info').' <>;=#{}' ), ); return parent::renderForm(); } } In the database for the table ps_category_lang I added ALTER TABLE ps_category_lang ADD headingh1 varchar(255); I cleared the cache - the field cannot be seen in categories .. What's next? Link to comment Share on other sites More sharing options...
ITDWX Andras Posted January 3, 2020 Share Posted January 3, 2020 Override not working in 1.7.6 or above... Use hooks building a custom module, see here: https://stackoverflow.com/questions/57552868/add-custom-field-in-prestashop-1-7-6-category-with-a-module-how-to-save-in-data Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now