Jump to content

Add new field to Categories


Recommended Posts



I am working on a shop which requires a custom field to be displayed in the Categories. I want to be able to display the country of origin next to a category.


So far I added a new column in the "ps_categories_lang" table.


I then added the variable to my category.php:

public $origin;


Still in category.php I replicated this (approx Lines 113-119) :

'origin' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isString'),


And it here (approx Line 525):

$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.*, cl.id_lang, cl.name, cl.description, cl.link_rewrite, cl.meta_title, cl.meta_keywords, cl.meta_description, cl.origin


Then, in my AdminCategoryController.php I replicated this (approx lines 57-80):

'origin' => array(
'title' => $this->l('Origin'),
'width' => 'auto'


And also added the input field here (approx Lines 327- 400):

'type' => 'text',
'label' => $this->l('Origin:'),
'name' => 'origin',
'lang' => true,


I also added the variable to my Front Office and it is showing as expected when I entered a value by hand in phpmyadmin.

It is also showing in the correct field in the "edit category page, and in my category listings (I can also sort my categories according to this variable). See the attached images


post-406658-0-85751600-1356074909_thumb.jpg post-406658-0-22550500-1356074907_thumb.jpg post-406658-0-81834300-1356074911_thumb.jpg


However, I cannot change the value through Prestashop. Any change I make in the field is not saved in the sql table.

I'd be happy if somebody could point me in the right direction as I don't want to do this through phpmyadmin at all...



Edited by Unknownst (see edit history)
Link to comment
Share on other sites

I am not sure if this will help, but someone posted a very short but concise tutor on making a payment module. I bookmarked it and was planning on studying it at a later date. I suspect it will have a clear example of what you are trying to do.




I am interested in accomplishing several things along the lines of what you are trying to do here. If you find the solution, I would appreciate it if you would post the answer here so that we all can learn.

Link to comment
Share on other sites

Thanks for the feedback.


Ya, I tried installs of 1.5x 3 times and gave up.

There are plenty of reports from developers that 1.5 is a mess.

I have decided to stay with 1.4.9 for at least another two years

until the mess is sorted out.


I had held off doing anything major with 1.4x because PrestaShop

advertised that 1.5 would have a good order edit feature. When I

took a look at what they did, I was unimpressed and started writing

my own routines for 1.4x.

Edited by jwzumwalt (see edit history)
Link to comment
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...