title: How to add custom field in combination tab of product & display the value in front end in Prestashop?
body: <p>I am a website about jute products and dome of the features vary according to the attributes of the product. 
  So what I need to do is to add custom field in the combination tab and then displaying the value of this field in Front end along with the product Features.
  In my PS 1.6.0.14 installation I have managed to successfully add the field and fill it from the backoffice but the value it not getting saved (It disappears on page reload). 
  What I did is this : (the name of the field is Packing Per Bale)</p>
  
  <ul>
  <li><p>Added the column packing_per_bale as varchar(250) in ps_product_attribute table.</p></li>
  <li><p>Modified Combination.tpl in the theme folder to add the field for Packing per bale</p></li>
  </ul>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="form-group"&gt;
  &lt;label class="control-label col-lg-3" for="attribute_packing_per_bale"&gt;
  {l s='Packing Per Bale'}
  &lt;/label&gt;
  &lt;div class="col-lg-5"&gt;
  &lt;input maxlength="250" type="text" id="attribute_packing_per_bale" name="attribute_packing_per_bale" value="" /&gt;
  &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <ul>
  <li><p>Modified Combination.php to declare the variable &amp; define it.</p>
  
  <p><code>59.  public $packing_per_bale;</code></p>
  
  <p><code>75.  'packing_per_bale' =&gt;    array('type' =&gt; self::TYPE_STRING, 'size' =&gt; 250),</code></p></li>
  <li><p>Modified Product.php : a) In addProductAttribute function</p>
  
  <pre><code>public function addProductAttribute($price, $weight, $unit_impact, $ecotax, $quantity, $id_images, $reference, $packing_per_bale,
      $id_supplier = null, $ean13, $default, $location = null, $upc = null, $minimal_quantity = 1)
  {
      Tools::displayAsDeprecated();
  
      $id_product_attribute = $this-&gt;addAttribute(
          $price, $weight, $unit_impact, $ecotax, $id_images,
          $reference, $packing_per_bale, $ean13, $default, $location, $upc, $minimal_quantity
      );
  </code></pre></li>
  </ul>
  
  <p>b) In addCombinationEntity function </p>
  
  <pre><code>public function addCombinationEntity($wholesale_price, $price, $weight, $unit_impact, $ecotax, $quantity,
          $id_images, $reference, $packing_per_bale, $id_supplier, $ean13, $default, $location = null, $upc = null, $minimal_quantity = 1,  array $id_shop_list = array(), $available_date = null)
      {
          $id_product_attribute = $this-&gt;addAttribute(
              $price, $weight, $unit_impact, $ecotax, $id_images,
              $reference, $packing_per_bale, $ean13, $default, $location, $upc, $minimal_quantity, $id_shop_list, $available_date);
          $this-&gt;addSupplierReference($id_supplier, $id_product_attribute);
  </code></pre>
  
  <p>c) In updateAttribute function</p>
  
  <pre><code>public function updateAttribute($id_product_attribute, $wholesale_price, $price, $weight, $unit, $ecotax,
          $id_images, $reference, $packing_per_bale, $ean13, $default, $location = null, $upc = null, $minimal_quantity = null, $available_date = null, $update_all_fields = true, array $id_shop_list = array())
      {
          $combination = new Combination($id_product_attribute);
  
          if (!$update_all_fields)
              $combination-&gt;setFieldsToUpdate(array(
                  'price' =&gt; !is_null($price),
                  'wholesale_price' =&gt; !is_null($wholesale_price),
                  'ecotax' =&gt; !is_null($ecotax),
                  'weight' =&gt; !is_null($weight),
                  'unit_price_impact' =&gt; !is_null($unit),
                  'default_on' =&gt; !is_null($default),
                  'minimal_quantity' =&gt; !is_null($minimal_quantity),
                  'available_date' =&gt; !is_null($available_date),
              ));
  
          $price = str_replace(',', '.', $price);
          $weight = str_replace(',', '.', $weight);
  
          $combination-&gt;price = (float)$price;
          $combination-&gt;wholesale_price = (float)$wholesale_price;
          $combination-&gt;ecotax = (float)$ecotax;
          $combination-&gt;weight = (float)$weight;
          $combination-&gt;unit_price_impact = (float)$unit;
          $combination-&gt;reference = pSQL($reference);
          $combination-&gt;packing_per_bale = pSQL($packing_per_bale);
          $combination-&gt;location = pSQL($location);
          $combination-&gt;ean13 = pSQL($ean13);
          $combination-&gt;upc = pSQL($upc);
          $combination-&gt;default_on = (int)$default;
          $combination-&gt;minimal_quantity = (int)$minimal_quantity;
          $combination-&gt;available_date = $available_date ? pSQL($available_date) : '0000-00-00';
  </code></pre>
  
  <p>d) In addAttribute function</p>
  
  <pre><code>public function addAttribute($price, $weight, $unit_impact, $ecotax, $id_images, $reference, $packing_per_bale, $ean13,
                                   $default, $location = null, $upc = null, $minimal_quantity = 1, array $id_shop_list = array(), $available_date = null)
      {
          if (!$this-&gt;id)
              return;
  
          $price = str_replace(',', '.', $price);
          $weight = str_replace(',', '.', $weight);
  
          $combination = new Combination();
          $combination-&gt;id_product = (int)$this-&gt;id;
          $combination-&gt;price = (float)$price;
          $combination-&gt;ecotax = (float)$ecotax;
          $combination-&gt;quantity = 0;
          $combination-&gt;weight = (float)$weight;
          $combination-&gt;unit_price_impact = (float)$unit_impact;
          $combination-&gt;reference = pSQL($reference);
          $combination-&gt;packing_per_bale = pSQL($packing_per_bale);
          $combination-&gt;location = pSQL($location);
          $combination-&gt;ean13 = pSQL($ean13);
          $combination-&gt;upc = pSQL($upc);
          $combination-&gt;default_on = (int)$default;
          $combination-&gt;minimal_quantity = (int)$minimal_quantity;
          $combination-&gt;available_date = $available_date;
  </code></pre>
  
  <p>e) In getAttributesGroups function </p>
  
  <pre><code>public function getAttributesGroups($id_lang)
      {
          if (!Combination::isFeatureActive())
              return array();
          $sql = 'SELECT ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name,
                      a.`id_attribute`, al.`name` AS attribute_name, a.`color` AS attribute_color, product_attribute_shop.`id_product_attribute`,
                      IFNULL(stock.quantity, 0) as quantity, product_attribute_shop.`price`, product_attribute_shop.`ecotax`, product_attribute_shop.`weight`,
                      product_attribute_shop.`default_on`, pa.`reference`, pa.`packing_per_bale`, product_attribute_shop.`unit_price_impact`,
                      product_attribute_shop.`minimal_quantity`, product_attribute_shop.`available_date`, ag.`group_type`
                  FROM `'._DB_PREFIX_.'product_attribute` pa
  </code></pre>
  
  <ul>
  <li>Modified Productcontroller</li>
  </ul>
  
  <p>Funtion processProductAttribute:</p>
  
  <pre><code>    886.  Tools::getValue('attribute_plazo_envio'),
  
      918.  Tools::getValue('attribute_plazo_envio'),
  </code></pre>
  
  <p>Function initFormInformations:</p>
  
  <pre><code>array_push($product_props, 'reference', 'plazo_envio', 'ean13', 'upc',
          'available_for_order', 'show_price', 'online_only',
          'id_manufacturer'
          );
  </code></pre>
  
  <p>Function renderListAttributes:</p>
  
  <pre><code>$comb_array[$combination['id_product_attribute']]['plazo_envio'] = $combination['plazo_envio'];
  </code></pre>
  
  <ul>
  <li>Modified ProductsController.php:</li>
  </ul>
  
  <p>function assignAttributesGroups:</p>
  
  <pre><code>464. $combinations[$row['id_product_attribute']]['plazo_envio'] = $row['plazo_envio'];
  </code></pre>
  
  <ul>
  <li>Modified product.js </li>
  </ul>
  
  <p>a)In function editProductAttribute</p>
  
  <pre><code>291.  var packing_per_bale = data[0]['packing_per_bale']
  </code></pre>
  
  <p>b)Added packing_per_bale in declaration of fillCombination function as a arguement </p>
  
  <p>c) In fillCombination Function</p>
  
  <pre><code>this.fillCombination = function(wholesale_price, price_impact, weight_impact, unit_impact, reference, packing_per_bale,
      ean, quantity, image, old_attr, id_product_attribute, default_attribute, eco_tax, upc, minimal_quantity, available_date)
      {
          var link = '';
          self.init_elems();
          $('#stock_mvt_attribute').show();
          $('#initial_stock_attribute').hide();
          $('#attribute_quantity').html(quantity);
          $('#attribute_quantity').show();
          $('#attr_qty_stock').show();
  
          $('#attribute_minimal_quantity').val(minimal_quantity);
  
          getE('attribute_reference').value = reference;
  
          getE('attribute_packing_per_bale').value = packing_per_bale;
  </code></pre>
  
  <p>The result is that I can successfully add text in text box when I edit a combination, and I can fill it the text box, press save  BUT on page load I the text box is empty in the backoffice.</p>
  
  <p>I hope someone can help me to accomplish this task, it seems I am very close to manage it.</p>