Jump to content

Problem with custom field in category


herwaldi

Recommended Posts

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

  • 3 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...