prestashop: add custom column on product page and display it on product.tpl

Steps:

  1. Create the table manually on the database.
  2. Declare the variable on .../classes/Product.php

 

 

 

 

    public static function getProduct_Documents($id_product)
   
   {

      
      $sql = 'select
               product_document.document_name,
                    product_document.document_url
            from
               product
               left join product_document ON product.id_product = product_document.id_product
            WHERE
               product_document.id_product = '.$id_product.' ;

   ';
//    echo $sql;
      
      $document_urls = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
      
//    print_r($document_urls);


      return $document_urls;
   }
   
   
   

 

 

 
  1. add the variable on .../controllers/front/ProductController.php in the following matter.

 

$document_urls1 = Product::getProduct_Documents((int) Tools::getValue('id_product'));
$this->context->smarty->assign('myArray', $document_urls1);

 

 

 

 

4. Add the field on your .../themes/classic/templates/catalog/product.tpl

 

 

{$myArray|@print_r}

 

{$tariff_code}

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *