文件一:/data/wwwroot/auto/catalog/view/theme/pav_bigmart/template/common/product/default.tpl
追加:
<span class="wl20161228_reviews" style="display: block;"> <?php if(!empty($product['review_count'])) echo @"(".$product['review_count']."reviews)"; ?> </span>
文件二:/data/wwwroot/auto/catalog/model/catalog/product.php
追加:
public function get_review_count($product_id) { $sql = "SELECT COUNT(DISTINCT `review_id`) AS total FROM `" . DB_PREFIX . "review` WHERE `product_id`=" . $product_id; $query = $this->db->query($sql); $query = $query->row; if (!empty($query['total'])) { return $query['total']; } return 0; }
文件三:/data/wwwroot/auto/system/pavothemes/widget/product_scroll.php
追加位置:return data 之前
foreach ($data as $key => $value) { $pr_id = $value['product_id']; $data[$key]['review_count'] = $this->model_catalog_product->get_review_count($pr_id); }