OpenCart 🇺🇦

Схема

public mixed review ( )

Аргументы

Аргумент Возможный тип Описание
У метода нет аргументов

Описание

Метод пока еще не документирован.

Исходный код

$this->language->load('product/product');

$this->load->model('catalog/review');

$this->data['text_on'] = $this->language->get('text_on');
$this->data['text_no_reviews'] = $this->language->get('text_no_reviews');

if (isset($this->request->get['page'])) {
	$page = $this->request->get['page'];
} else {
	$page = 1;
}

$this->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) * 5, 5);

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 = 5;
$pagination->text = $this->language->get('text_pagination');
$pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}');

$this->data['pagination'] = $pagination->render();

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/review.tpl')) {
	$this->template = $this->config->get('config_template') . '/template/product/review.tpl';
} else {
	$this->template = 'default/template/product/review.tpl';
}

$this->response->setOutput($this->render());