Jump to content

how i can add custom fields in product on prestashop 1.5.3?


Recommended Posts

Hello i want to add 2 extra custom fields on the product's page. i used this tutorial on the pass when i was on 1.4 http://strife.pl/2011/12/how-to-add-new-custom-field-in-prestashop/ put now this tutorial is not working for 1.5.3 because is not any AdminProducts.php in /[admin_panel]/tabs/AdminProducts.php

Does any one know how i can do it? i'm looking an english solution. Thank you

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

Please, take a look at our Product Tabs module. It may be interesting for you. The module is compatible with PrestaShop 1.5.3. and provides multilingual support. Feel free to reply with any other questions or concerns.

 

Best regards.

i dont want to addd tab on my products. I just want to add an extra field

Link to comment
Share on other sites

The equivalent to AdminProducts.php is now admin/themes/default/template/controllers/products/informations.tpl or similar (depending on which sub-tab you want to add your field).

v.1.5 relies more on Smarty to generate these pages.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

any idea of adding extra field in product combination tab.

i am using prestashop 1.4.7.3

i did in product info tab it is working but in combination tab it is not inserting value in database..

 

please help me out i am fed up of this issue :(

 

i have done like this for product info tab

 

but i have problem with adding extra field in combination tab

 

http://strife.pl/2011/12/how-to-add-new-custom-field-in-prestashop/

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

any idea of adding extra field in product combination tab.

i am using prestashop 1.4.7.3

i did in product info tab it is working but in combination tab it is not inserting value in database..

 

please help me out i am fed up of this issue :(

 

i have done like this for product info tab

 

but i have problem with adding extra field in combination tab

 

http://strife.pl/201...-in-prestashop/

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Is it possible to add more than just a text or file upload field to the product customizations? That really doesn't do much to customize the product. I'm looking for a way to add drop down boxes like in the attributes section so customers can pick styles for embroidery. But I want them to show up in the customization tab, not in the options section.

  • Like 1
Link to comment
Share on other sites

  • 7 months later...

add a simple field to PrestaShop, from a development standpoint, i.e. implementable installable module is horrible...it's really to bad as so many nice and cool features could be done...now it's forced that we add an additional tab...otherwise...we have to hack it....

 

for example, it would take  'nothinga ' to add a mrsp module..but do we really want need to add a new tab or otherwise create something as described that could 'not' today be accepted in addon's...

 

thanks in advance for letting me explain my view of current  ps and  backoffice module writing...

Link to comment
Share on other sites

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

 

I only have this file in Default theme, but i am not using this theme. Will this be a problem?

 

In my theme i don't have a file with that name

 

Forget This

 

I was being dumb. It worked fine.

 

EDIT:

 

Nevertheless i am having a problem.

 

The Field that i've added is like a "Recommended Street Retail price"

 

So i've added in product.php

 

In object:

 

/** @var float pvpr */
public $pvpr = 0;
 
In Definition:
 
'pvpr' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice'),
 
 
in prices.tpl i've added

 

 <tr>
            <td class="col-left">
                <label>{l s='PVPr c/IVA:'}</label>
            </td>
            <td style="padding-bottom:5px;">
                <input type="text" id="pvpr" name="pvpr" value="{$product->pvpr|default:''}"/>
            </td>
        </tr>
<br />
 
 
However in the backoffice when i try to input the value, i receive this error:
 
 

post-400164-0-83840700-1385418861_thumb.png

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

[Adicional information... i've replaced with my original backup files and dropped the field in the table... and the problem persists...

 

After that i've dropped my db and put back an backup from this morning, before doing anything. problem persists.

 

Is it possible that it is a totally different issue?]

 

Forget this

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

Problem is in product.php code:

 

So i've added in product.php

 

In object:

 

/** @var float pvpr */
public $pvpr = 0;
 
In Definition:
 
'pvpr' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice'),
 
 
I've noticed i was not using the correct backup file, when i used it all became normal.
 
Can someone give me an idea we're is the problem in this code?
Link to comment
Share on other sites

  • 1 month later...

Hi nspinheiro,

 

I've followed the instructions and I got the same error "An error occurred while updating an object. product ()when I tried to save the changes.

 

May I know what have you change to solve this?

 

in my information.tpl I've added

 

 

<!-- added warranty field -->
<tr>
<td class="col-left">
                <label>{l s='Warranty:'}</label>
</td>
<td style="padding-bottom:5px;">
<input type="text" id="warranty" name="warranty" size="80" value="{$product->warranty|default:''}"/>
</td>
</tr>

 

<!-- added warranty field -->

 

in Product.php I've added:

 

/** @var string Warranty */

public $warranty;
 
'fields' => array(
// Classic fields
    'warranty'   =>                             array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml'), 
Link to comment
Share on other sites

  • 3 months later...
  • 2 months later...

I've got a question about Vekia's tutorial.

 

What do I need to change to let it work for a dropdown box?
I used the same method as condition (but does not work)
Getting the error: "An error occurred while updating an object. product ()when I tried to save the changes.

//Product.php

            'name_category_gg' =>             array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isGenericName', 'values' => array('option a', 'option b'), 'default' => 'option a'),



and in my informations.tpl file:
 


//informations.tpl

<td style="padding-bottom:5px;">
			<select name="name_category_gg" id="name_category_gg">
				
<option value="option a" {if $product->name_category_gg == 'option a'}selected="selected"{/if}> option a </option>
<option value="option b" {if $product->name_category_gg == 'option b'}selected="selected"{/if}> option b </option>

			</select>
		</td>

Hope someone can help.

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

Sure.

 

Error: Column: name_category_gg did not exist.

I created an extra column (name_category_gg) in table product not in table product_shop.

So went back to my product.php and edit this line:

//product.php

 'name_category_gg' =>             array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isGenericName', 'values' => array('option a', 'option b'), 'default' => 'option a')

to:
 

 'name_category_gg' =>             array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'values' => array('option a', 'option b'), 'default' => 'option a')

Now it's working.

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

  • 8 months later...

 

Hello!

 

I tried following this manual in order to add a new field called : "Warranty" in order to add terms of warranty to the product page but i get errors all the time,

I think it is related to this line in your manual that i didn't understand and did not know what to do with it: "always be sure the extra field is added to the definitions list before calling the parent constructor"

Can you explain to me what does this mean and what do i need to edit in order to add the warranty field i added in the ps_product table to the definitions list?

This wasn't clear in your manual.

 

Thank you

 

p.s. I'm using Prestashop 1.6.0.11

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

  • 2 years later...

For ex,

I created a dropdown box field.

 

 

I clicked “yes” option to all created field then go to click save button.

 

 

Refer in my page, value is not set in my product page.

 

 

Dropdown value is not updated in the database. 

 

code:

classes/product.php:

public $hazmat_fees;

public $poison_pack;

public $refrigerated_fees;

prestashop/themes/default/template/controllers/products/information.tpl

<div class="form-group">

<div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="hazmat_fees" type="default"}</span></div>

<label class="control-label col-lg-2" for="hazmat_fees">

{l s='Hazmat Fees:'}</label>

</label>

<div class="col-lg-3">

<select name="hazmat_fees" id="hazmat_fees">

<option value="1" {if $product->hazmat_fees == '1'}selected="selected"{/if} >{l s='Yes'}</option>

<option value="0" {if $product->hazmat_fees == '0'}selected="selected"{/if} >{l s='No'}</option>

</select>

</div>

</div>

 

<div class="form-group">

<div class="col-lg-1"><span class="pull-right">

{include file="controllers/products/multishop/checkbox.tpl" field="poison_pack" type="default"}</span></div>

<label class="control-label col-lg-2" for="poison_pack">{l s='Poison Pack:'}</label>

<div class="col-lg-3">

<select name="poison_pack" id="poison_pack">

<option value="1" {if $product->poison_pack == '1'}selected="selected"{/if} >{l s='Yes'}</option>

<option value="0" {if $product->poison_pack == '0'}selected="selected"{/if} >{l s='No'}</option>

</select>

</div>

</div>

<div class="form-group">

<div class="col-lg-1"><span class="pull-right">

{include file="controllers/products/multishop/checkbox.tpl" field="refrigerated_fees" type="default"}</span></div>

<label class="control-label col-lg-2" for="refrigerated_fees">{l s='Refrigerated Fees:'}</label>

<div class="col-lg-3">

<select name="refrigerated_fees" id="refrigerated_fees">

<option value="1" {if $product->refrigerated_fees == '1'}selected="selected"{/if} >{l s='Yes'}</option>

<option value="0" {if $product->refrigerated_fees == '0'}selected="selected"{/if} >{l s='No'}</option>

</select>

</div>

</div>

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

×
×
  • Create New...