Prestashop custom fields in products admin section

→ Are you a new visitor? Please visit the page guidance for new visitors ←

Prestashop custom fields in products admin section

I had to do this modification on an existing prestashop project few months ago and I had to add some custom fields in products admin section. In this tutorial I’ll try to show you how you create new product field in admin on product edit page (informations tab). Of course you will be able to fill field with own value and this value will be stored in database. Let’s see it more clearly with a picture:

presta

We need now to create a new field in ps_product table.

  • Alter ps_product table.
  • Add new VARCHAR(50) field name called “custom_information” for example. In this field we will store our new product related information.

Now, in prestashop we have product.php file which corresponds to the logic of the products and products table.

This is located in the following path:

ADMIN_DIR/classes/Product.php

This should be modified like this:

Basically we add our new field here as a property. We need also to extend object definition like this: Add

to object definition code.

Next step is to add some code to the template that is responsible with this page. We must modify informations.tpl file located in this path:

ADMIN_DIR/themes/default/template/controllers/products/informations.tpl

Here you will find a tabular structure in which you see all the other fields from admin.

You add something like this there:

That’s all. A new input field will be rendered there and saved with the other informations in the database when you perform a save operation. In the same way you can make other changes as well and add multiple fields to the product page.

Request an article ←