Jump to content

How to call a function and display it in a TPL file?


Recommended Posts

I am trying to show product favorite count on my product page (inside the favoriteproducts module's tpl file)

 

But i dont know how to call a function from php and show it in a tlp file. I have tried to assign val with different ways but it always return "0" or null. I will be very happy if you show me the right way. :mellow:

 

FavoriteProduct.php

 



public static function FavoriteProductsCount($id_product)
{
  $favorite_count = Db::getInstance()->getValue('
   SELECT COUNT(*)
   FROM `'._DB_PREFIX_.'favorite_product`
   WHERE `id_product` = '.(int)$id_product
   );

   return $favorite_count;
}

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

×
×
  • Create New...