Dmcwebd Posted November 27, 2010 Share Posted November 27, 2010 I need to add the product comment at the product footer.I changed the Php code to hook on product footer but the module isnt working.Can anyone help me with the right code that would work?I'm adding using the code so it wont need the tab.tpl anymore.here is the original php code. public function hookProductTab($params) { global $smarty; global $cookie; require_once(dirname(__FILE__).'/ProductComment.php'); require_once(dirname(__FILE__).'/ProductCommentCriterion.php'); $smarty->assign(array( 'comments' => ProductComment::getByProduct(intval($_GET['id_product'])), 'criterions' => ProductCommentCriterion::getByProduct(intval($_GET['id_product']), intval($cookie->id_lang)), 'nbComments' => intval(ProductComment::getCommentNumber(intval($_GET['id_product']))) )); return ($this->display(__FILE__, '/tab.tpl')); } public function hookProductTabContent($params) { global $smarty, $cookie, $nbProducts; $commentNumber = intval(ProductComment::getCommentNumber(intval(Tools::getValue('id_product')))); $averages = ProductComment::getAveragesByProduct(intval(Tools::getValue('id_product')), intval($cookie->id_lang)); $customerComment = ProductComment::getByCustomer(intval(Tools::getValue('id_product')), intval($cookie->id_customer), true); $averageTotal = 0; foreach ($averages AS $average) $averageTotal += floatval($average); $averageTotal = count($averages) ? ($averageTotal / count($averages)) : 0; $smarty->assign(array( 'logged' => intval($cookie->id_customer), 'action_url' => Tools::safeOutput($_SERVER['PHP_SELF']).'?'.$_SERVER['QUERY_STRING'], 'comments' => ProductComment::getByProduct(intval(Tools::getValue('id_product'))), 'criterions' => ProductCommentCriterion::getByProduct(intval(Tools::getValue('id_product')), intval($cookie->id_lang)), 'averages' => $averages, 'product_comment_path' => $this->_path, 'averageTotal' => $averageTotal, 'too_early' => ($customerComment AND (strtotime($customerComment['date_add']) + self::DELAY * 3600) > time()), 'delay' => self::DELAY )); $nbProducts = $commentNumber; require_once(dirname(__FILE__).'/../../pagination.php'); return ($this->display(__FILE__, '/productcomments.tpl')); } public function hookHeader() { $this->_frontOfficePostProcess(); } 1 Link to comment Share on other sites More sharing options...
dukeshiva Posted February 21, 2014 Share Posted February 21, 2014 (edited) This worked for me to Hook Most viewed products under product details (productTabContent). Module Install Method: public function install() { if (!parent::install() || !$this->registerHook('productTabContent') return false; return true; } Hook method: public function hookProductTabContent($params) { /*Code*/ } You need to reinstall the module if you already installed it. Edited February 21, 2014 by dukeshiva (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now