opencart默认产品评价每页只显示5条,如何增加?
比如你想每页显示20条,那么,找到以下文件:
/catalog/controller/product/product.php
Search for
5;
and replace it with
20;
(所有的5改成20)
OC2.X 版本代码:
public function review() {
$this->load->language('product/product');
$this->load->model('catalog/review');
$data['text_no_reviews'] = $this->language->get('text_no_reviews');
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
$data['reviews'] = array();
$review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']);
$results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page – 1) * 20, 20);
foreach ($results as $result) {
$data['reviews'][] = array(
'author' => $result['author'],
'text' => nl2br($result['text']),
'rating' => (int)$result['rating'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added']))
);
}
$pagination = new Pagination();
$pagination->total = $review_total;
$pagination->page = $page;
$pagination->limit = 20;
$pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}');
$data['pagination'] = $pagination->render();
$data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page – 1) * 20) + 1 : 0, ((($page – 1) * 20) > ($review_total – 20)) ? $review_total : ((($page – 1) * 20) + 20), $review_total, ceil($review_total / 20));
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/review.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/review.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/product/review.tpl', $data));
}
}
OC1.5.6.4 代码只要改三个地方:
$results = $this->model_catalog_review->getReviewsByProductId($this->request->get[‘product_id’], ($page – 1) * 20, 20);
foreach ($results as $result) {
$this->data[‘reviews’][] = array(
‘author’ => $result[‘author’],
‘text’ => $result[‘text’],
‘rating’ => (int)$result[‘rating’],
‘reviews’ => sprintf($this->language->get(‘text_reviews’), (int)$review_total),
‘date_added’ => date($this->language->get(‘date_format_short’), strtotime($result[‘date_added’]))
);
}
$pagination = new Pagination();
$pagination->total = $review_total;
$pagination->page = $page;
$pagination->limit = 20;
$pagination->text = $this->language->get(‘text_pagination’);
$pagination->url = $this->url->link(‘product/product/review’, ‘product_id=’ . $this->request->get[‘product_id’] . ‘&page={page}’);