Jump to content

Add custom field in category


Recommended Posts

I need to add a custom field in categories.

I have followed this tutorial : http://www.paulineghiazza.fr/prestashop-1-5-ajouter-un-champ-pour-les-categories-et-activer-lediteur/

I've added the new column in the table ps_category_lang (named "champ_h1")


I've added the following line in $definition in the class Category : 
 'champ_h1' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'size' => 128),


In AdminCategoriesController.php,


I've updated $this->fields_list in the constructor with

'champ_h1' => array(
'title' => $this->l('H1')
And $this->fields_form in renderForm() with : 
'type' => 'text',
'label' => $this->l('H1'),
'name' => 'champ_h1',
'lang' => true,
'hint' => $this->l('Invalid characters:').' <>;=#{}',
When I navigate in the categories, a column H1 is now there.
The input H1 is also there in the form
If I put some value in the input and save the form, it's correctly save ine the database.
If I navigate in the categories, the column H1 is filled with the value for the category, and I can make search on it.
But if I come back in the form, the field is empty.
And if I use {$category->champ_h1} in category.tpl, it's empty too.
Can you help me plz ?


Share this post

Link to post
Share on other sites

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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More