Jump to content

Welcome, Guest!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

zimmer-media

How to add an extra field on product page

Recommended Posts

step 1 Add an entry to the database in the table prefix_product (for example name and lenght - what you need)

0_1514159821465_5ae550fd-3379-49ab-9281-d0909e99e80f-grafik.png

step 2.1 modify the file “Product.php” from “/classes/Product.php”, preferably in the folder classes Override “/override/classes/Product.php” save see the lines /** @var int Supplier id */ public $id_supplier; /** @var int default Category id */ public $id_category_default; /** @var int default Shop id */ public $id_shop_default; /** @var string Manufacturer name */ public $manufacturer_name; just add the following /** @var string new_field */ public $new_field; step 2.2 for example find 'id_supplier' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'], 'reference' => ['type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 32], after this add 'new_field' => ['type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 200], step 3 copy your informations.tpl under override / controllers / admin / templates / products / informations.tpl for example and find the code (depending on where this additional field should appear.) <div class="form-group"> <div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="name" type="default" multilang="true"}</span></div> <label class="control-label col-lg-2 required" for="name_{$id_lang}"> <span class="label-tooltip" data-toggle="tooltip" title="{l s='The public name for this product.'} {l s='Invalid characters:'} &lt;&gt;;=#{}"> {l s='Name'} </span> </label> <div class="col-lg-5"> {include file="controllers/products/input_text_lang.tpl" languages=$languages input_class="{$class_input_ajax}{if !$product->id || Configuration::get('PS_FORCE_FRIENDLY_PRODUCT')}copy2friendlyUrl{/if} updateCurrentText" input_value=$product->name input_name="name" required=true } </div> </div> after this insert <div class="form-group"> <div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="name" type="default" multilang="true"}</span></div> <label class="control-label col-lg-2"> <span class="label-tooltip" data-toggle="tooltip" title="{l s='The additional field for your product'} {l s='Invalid characters:'} &lt;&gt;;=#{}"> {l s='New Field'} </span> </label> <div class="col-lg-5"> <input type="text" id="new_field" name="new_field" value="{$product->new_field|default:''}"/> </div> </div> step 4 if you want to see this field in your frontoffice product view - in your theme product.tpl add the follow code with h1-6 tag or p tag in your tpl {$product->new_field|escape:'html':'UTF-8'}

product admin 0_1514161186516_9fbcf2bd-759e-47b4-b6db-947f039a4ab1-grafik.png

product front office before 1_1514161289031_Screenshot-2017-12-25 Soap.png0_1514161289031_Screenshot-2017-12-25 Candle.png

product front office after changes 1_1514161355504_Screenshot-2017-12-25 Soap1.png0_1514161355504_Screenshot-2017-12-25 Candle1.png

Share this post


Link to post
Share on other sites

Hi,

Is this workable with Niara theme? I hope someone will develop a module for product extra field soon..

Share this post


Link to post
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...