public function hookExtraProductComparison($params) { require_once dirname(__FILE__) . '/ProductComment.php'; require_once dirname(__FILE__) . '/ProductCommentCriterion.php'; $list_grades = array(); $list_product_grades = array(); $list_product_average = array(); $list_product_comment = array(); foreach ($params['list_ids_product'] as $id_product) { $grades = ProductComment::getAveragesByProduct($id_product, $this->context->language->id); $criterions = ProductCommentCriterion::getByProduct($id_product, $this->context->language->id); $grade_total = 0; if (count($grades) > 0) { foreach ($criterions as $criterion) { if (isset($grades[$criterion['id_product_comment_criterion']])) { $list_product_grades[$criterion['id_product_comment_criterion']][$id_product] = $grades[$criterion['id_product_comment_criterion']]; $grade_total += (double) $grades[$criterion['id_product_comment_criterion']]; } else { $list_product_grades[$criterion['id_product_comment_criterion']][$id_product] = 0; } if (!array_key_exists($criterion['id_product_comment_criterion'], $list_grades)) { $list_grades[$criterion['id_product_comment_criterion']] = $criterion['name']; } } $list_product_average[$id_product] = $grade_total / count($criterions); $list_product_comment[$id_product] = ProductComment::getByProduct($id_product, 0, 3); } } if (count($list_grades) < 1) { return false; } $this->context->smarty->assign(array('grades' => $list_grades, 'product_grades' => $list_product_grades, 'list_ids_product' => $params['list_ids_product'], 'list_product_average' => $list_product_average, 'product_comments' => $list_product_comment)); return $this->display(__FILE__, '/products-comparison.tpl'); }
* needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <*****@*****.**> * @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 1.4 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ require_once dirname(__FILE__) . '/../../classes/Validate.php'; require_once dirname(__FILE__) . '/../../classes/Db.php'; require_once dirname(__FILE__) . '/../../classes/Tools.php'; require_once dirname(__FILE__) . '/ProductCommentCriterion.php'; if (empty($_GET['id_lang']) === false && isset($_GET['id_product']) === true) { $criterions = ProductCommentCriterion::get($_GET['id_lang']); if ((int) $_GET['id_product']) { $selects = ProductCommentCriterion::getByProduct($_GET['id_product'], $_GET['id_lang']); } echo '<select name="id_product_comment_criterion[]" id="id_product_comment_criterion" multiple="true" style="height:100px;width:360px;">'; foreach ($criterions as $criterion) { echo '<option value="' . (int) $criterion['id_product_comment_criterion'] . '"'; if (isset($selects) === true && sizeof($selects)) { foreach ($selects as $select) { if ($select['id_product_comment_criterion'] == $criterion['id_product_comment_criterion']) { echo ' selected="selected"'; } } } echo '>' . htmlspecialchars($criterion['name'], ENT_COMPAT, 'UTF-8') . '</option>'; } echo '</select>'; }
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 hookProductTabContent($params) { global $smarty, $cookie, $nbProducts; $commentNumber = intval(ProductComment::getCommentNumber(intval($_GET['id_product']))); $averages = ProductComment::getAveragesByProduct(intval($_GET['id_product']), intval($cookie->id_lang)); $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' => $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'], 'comments' => ProductComment::getByProduct(intval($_GET['id_product'])), 'criterions' => ProductCommentCriterion::getByProduct(intval($_GET['id_product']), intval($cookie->id_lang)), 'averages' => $averages, 'product_comment_path' => $this->_path, 'averageTotal' => $averageTotal)); $nbProducts = $commentNumber; require_once dirname(__FILE__) . '/../../pagination.php'; return $this->display(__FILE__, '/productcomments.tpl'); }
public function hookExtraProductComparison($params) { global $smarty, $cookie; $list_grades = array(); $list_product_grades = array(); $list_product_average = array(); $list_product_comment = array(); foreach ($params['list_ids_product'] as $id_product) { $grades = ProductComment::getAveragesByProduct((int) $id_product, (int) $cookie->id_lang); $criterions = ProductCommentCriterion::getByProduct((int) $id_product, (int) $cookie->id_lang); $grade_total = 0; if (sizeof($grades) > 0) { foreach ($criterions as $criterion) { $list_product_grades[$criterion['id_product_comment_criterion']][$id_product] = $grades[$criterion['id_product_comment_criterion']]; $grade_total += (double) $grades[$criterion['id_product_comment_criterion']]; if (!array_key_exists($criterion['id_product_comment_criterion'], $list_grades)) { $list_grades[$criterion['id_product_comment_criterion']] = $criterion['name']; } } $list_product_average[$id_product] = $grade_total / sizeof($criterion); $list_product_comment[$id_product] = ProductComment::getByProduct($id_product, 0, 3); } } if (sizeof($list_grades) < 1) { return false; } $smarty->assign(array('grades' => $list_grades, 'product_grades' => $list_product_grades, 'list_ids_product' => $params['list_ids_product'], 'list_product_average' => $list_product_average, 'product_comments' => $list_product_comment)); return $this->display(__FILE__, '/products-comparison.tpl'); }