Jump to content

Add extra fields on product page [PS 1.6]


tom3k_21

Recommended Posts

Hello,

I have a problem with adding extra field on product page based on tutoriale 

http://mypresta.eu/en/art/developer/new-field-product-backoffice.html

 

I have created table 'custom_field1' in ps_product

 

in class/Product.php added

public $custom_field1; 

and in public static $definition = array(


'custom_field1' =>  array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml'),

in admin7543\themes\default\template\controllers\products\features.php

 

<td class="col-left">
                <label>{l s='Feature1:'}</label>
            </td>
            <td style="padding-bottom:5px;">
                <input type="text" id="custom_field1" name="custom_field1" value="{$product->custom_field1|default:''}"/>
            </td>
 

field is showing but it doesent saving data only getting blank error:

Wystąpił błąd podczas aktualizacji obiektu. product ()

 

what else i have to chagne to save data and show the information on product page?

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

In the class:

'custom_field1' => array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isString', 'size' => 255),

And:

public $custom_field1;

In the TPL:

<td style="padding-bottom:5px;">
<input size="55" maxlength="255" type="text" name="custom_field1" value="{$product->custom_field1|htmlentitiesUTF8}" style="width: 150px; margin-right: 5px;" />
</td>

And I recommend you put the class and the controller in override folder ^^

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

  • 6 months later...
  • 3 months later...
  • 3 months later...
  • 1 year later...

In the class:

'custom_field1' => array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isString', 'size' => 255),

And:

public $custom_field1;

In the TPL:

<td style="padding-bottom:5px;">
<input size="55" maxlength="255" type="text" name="custom_field1" value="{$product->custom_field1|htmlentitiesUTF8}" style="width: 150px; margin-right: 5px;" />
</td>

And I recommend you put the class and the controller in override folder ^^

 

Hi, I recently installed prestashop 1.7 and would like to add/delete/modify some product fields. But your suggestions do not work on my prestashop version. The "\adminFolder\themes\default\template\controller\products\features.php" file does not exist. There is also no template related products. How do I make these changes?

Link to comment
Share on other sites

  • 7 months later...

The solution is working properly for one variable only, but if I would use two variables it doesn't work :( I use Prestashop 1.6.x and I see an error as above. Any solution?

My code in Product.php override is:

<?php
class Product extends ProductCore
{
    public $manufacturer_price;

    public $out_of_offer = false;

    public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
    {
        self::$definition['fields']['manufacturer_price'] = array('type' => self::TYPE_STRING, 'validate' => 'isString', 'shop' => true);
        self::$definition['fields']['out_of_offer'] = array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'shop' => true);
        parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
    }

}

The variable $out_of_offer would be also without "= false" but it doesn't work also :(

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