I’ve figured out how to add new field to database using Prestashop (1.4.3, but I think for the newer versions would be the same). This solution gives you new field in database and you will be able to edit / save data to this field in your admin panel, for my example I needed a field which was called “number of photos”. Below you can see how it works.

When you want to get it you should make some improvements. First of all just create a new field in your database it will be called “nb_photos” in my case.
|
1 |
ALTER TABLE `ps_product` ADD `nb_photos` INT UNSIGNED NOT NULL DEFAULT '0' |
And then:
1. Open AdminProducts.php file (/[admin_panel]/tabs/AdminProducts.php) and add this line (line 2194):
|
1 2 3 4 5 6 7 |
<tr>
<td class="col-left">'.$this->l('Number of photos:').'</td>
<td style="padding-bottom:5px;">
<input size="55" type="text" name="nb_photos" value="'.htmlentities($this->getFieldValue($obj, 'nb_photos'), ENT_COMPAT, 'UTF-8').'" style="width: 130px; margin-right: 44px;" />
<span class="hint" name="help_box">'.$this->l('Number of photos') . '</span>
</td>
</tr> |
2. Open Product.php (classes/Product.php) and add:
Line 130
|
1 2 |
/** @var integer Number of photos */
public $nb_photos; |
Line 231
|
1 2 3 |
'ean13' => 'isEan13',
'nb_photos' => 'isUnsignedInt', // this field
'upc' => 'isUpc', |
Line 340
|
1 2 3 |
$fields['ean13'] = pSQL($this->ean13);
$fields['nb_photos'] = pSQL($this->nb_photos);
$fields['upc'] = pSQL($this->upc); |
And that’s all.
If you need some more information about it just let me know using comments box

Miguel Rojas
/ March 16, 2012hello, great job !!!
any question… for modify ?????
Miguel Rojas
/ March 16, 2012but if field is a text field ???
‘my_new_field’ => ‘isUnsignedInt’, // this field ?????
‘my_new_field’ => ‘isText’ OR I NEED Tools:GetValue() ????????
Giacomo
/ April 2, 2012Thank a lot for your guide!
and to display this value in front office?
strife
/ June 12, 2012Hi,
I think you’ve already found the solution for it but let me anwer (maybe somebody else will need this information).
In frontend you should use something like that:
product.tpl
Let me know if it’s working or if you have any questions.
Thanks!
sepahan
/ April 10, 2012how to show this field in fo????
strife
/ June 12, 2012Have you tried this?
Best,
M
pradyuman
/ April 20, 2012Thank You very much…
I have used your instruction and it is working fine.
pradyuman
/ April 24, 2012Now I have just inserted a field as wholesaler price at admin panel and that is inserted at product table but how the wholesaler price will go to product page and how when a wholesaler will login at that time how he/she can buy their product with their wholesaler price not the retailer price.
I have already tried for grouping but grouping is not fullfilling my requirements then how will I do?
Please help me asap…I expect help from you.
strife
/ June 12, 2012I assume the issue is after getting a payment I am right? You want to put the new price instead of old one? :>
The ugly solution for this is … to make changes in the model. You can simply go to the model and put the condition if person is a wholesaler and then return the appropriate price.
Does it make sense?
Let me know if it’s still ready to solve
Best,
M
ania
/ June 18, 2012so how to make new field for ‘dollar price’, i use prestashop v.1.3.6.
please help me
thanks before
strife
/ June 18, 2012Hi,
That’s pretty simple if I understand well what you’ve said. What you’re gonna do is go to the product details and click to the “Prices” tab. And then you’ll see what you wanna get.
However, I am not sure if this is what you wanted. In other words it’s not necessary to make a new field for this
dollar pricecoz you can configure it already (All products can have a specific price for each currency).Even though, if you really want to create a new field you can just do it in the way that I wrote and print it out in the frontend this way (http://strife.pl/2012/06/how-to-change-the-original-price-in-prestashop/).
Let me know if this helps or not
Best,
M
VERO20
/ July 31, 2012Hello! how would you do that for text?
strife
/ September 11, 2012Hi VERO20,
You can do it by the same token as you’re doing it for integer. Check the whole Product.php and try to find any text fields and copy it. If you had problems let me know.
Best,
M
zounars
/ August 7, 2012Hello,
Thank you for your tutorial.
How can I add a datepicker to the custom field?
Thanks
Julius
/ August 11, 2012zounars
Try to use jquery ui datepicker. It is very easy to integrate.
antony
/ August 27, 2012add custom field in Combination tab
arnold
/ September 5, 2012Hello,
I tried your tutorial, the only difference is that custom field is an ENUM just like condition, with Prestashop 1.4.9 i’m getting:
An error occurred while updating object. product (), did anyone encounter this?
strife
/ September 11, 2012Hi arnold,
That’s interesting. Thanks for this spot. Do you have any more errors occurred? It’s quite less information to help you without working on your version …
M
Hernan
/ September 5, 2012Hello,
where insertion is performed on data, ie , the data insert.
in what php document or is in the same product.php
Jashen
/ September 11, 2012Hello every one, I am trying to integrate a date picker in order-carrier.php
But don’t it don’t seems to work. It is as if the css is not taken into consideration.
Any help will be welcome.
Thank you
strife
/ September 11, 2012Hi Jashen,
Tell me what you see in Firebug. Might the path is wrong, what you think about it?
Best,
M
Lucas
/ September 17, 2012Hi,
Im in big need of adding a text field to the check out-process. I need them to write a number (for identification) and I need to receive it.
Can I use any of your code for this?
Thanks.
strife
/ December 6, 2012Sorry for late reply.
Yes sure you can do whatever you do with this.
Best,
M
RBucci
/ December 12, 2012Strife,
I’m really grateful for your tutorial, however taking a closer look, I was wondering if you could give me a hand with what I need to do;
I’m creating a cart for a company that doesn’t have clients but employees. The employees are salesmen that will be connected to the website via a tablet each time they visit a client in order to send the order to the main office. The problem is that they need to be able to have the main price as well as a blank field in which they can input the price with which they agreed on with the final customer.
I’m in need to enable a blank textfield (modifiable by the employees) under the price in all the products pages before the “Add to Cart” button so that afterwards, in the Shopping Cart Summary it will behave like the normal price (adding the total to the bottom) and storing it as a record for the employees to keep track of their comissions in the order history. And if possible, including those prices in the confirmation email.
If there’s any way to do this, I will be able to sleep at night once again.. I’ve been trying very hard to do this but so far I got nowhere near..
Thank you so much for your time!!!
strife
/ December 12, 2012Hi RBucci,
Ok. So I can suggest you to modify the model in the Prestashop. What you need to do is:
Find the model for products and modify it in the way that enables you to affect to the price. I think you can use sessions because each of employers would put the price manually.
I mean something like this:
< ?php
function getPrice() {
// and here you can check if something is in the sessions
// and replace it instead of actual product price
}
?>
I don’t know if you want to replace the current price or just only add the new field above/below it. However, I understand that you want to replace it. And this solution should fix your problem. If not let me know.
Any questions feel free to ask.
Best,
Maciej
RBucci
/ December 12, 2012I really don’t understand what you mean with that code, Maciej. Maybe you could exemplify?
Thanks!!
carlos soratto
/ February 8, 2013PERFECT! THANKS!
Bruna
/ February 27, 2013Congratulation for your tutorial, it work very well!
You save my day Strife, thanks a lot!
(VERO20) FOR TEXT:
Instead of adding this:
‘nb_photos’ => ‘isUnsignedInt’, // this field
add this:
‘nb_photos’ => ‘isString’, // this field
and on the first step you need to alter the data type(INT for VARCHAR(100) or char(50))
ALTER TABLE
ps_productADDnb_photosVARCHAR(100) UNSIGNED NOT NULL DEFAULT ’0′TKS
Bruna
/ March 4, 2013Hi how can i add fields in a module tpl?
Thanks
muhsin
/ April 4, 2013Hai
i am new to prestashop and now i am creating custom API for a mobile app.
i want a custom sql query to get cart and cart products of a loged customer.