OpenCart
29
Вклад в тег
catalog/controller/product/product.php
$data['rating'] = (int)$product_info['rating'];
// Expanded rating
$this->load->model('catalog/review');
$review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']);
$estimations = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id']);
$one = 0;
$two = 0;
$three = 0;
$four = 0;
$five = 0;
$rating_sum = 0;
foreach ($estimations as $estimation){
($estimation['rating'] == '1') && $one++;
($estimation['rating'] == '2') && $two++;
($estimation['rating'] == '3') && $three++;
($estimation['rating'] == '4') && $four++;
($estimation['rating'] == '5') && $five++;
$rating_sum += $estimation['rating'];
}
$data['expanded_rating'][] = array(
'one' => round((100/$review_total) * $one),
'two' => round((100/$review_total) * $two),
'three' => round((100/$review_total) * $three),
'four' => round((100/$review_total) * $four),
'five' => round((100/$review_total) * $five),
'rating' => round($rating_sum / $review_total, 1),
'total' => $review_total
);
catalog/view/theme/default/template/product/product.twig
<p>{% for i in 1..5 %}
{% if rating < i %}<span class="fa fa-stack"><i class="fa fa-star-o fa-stack-1x"></i></span>{% else %}<span class="fa fa-stack"><i class="fa fa-star fa-stack-1x"></i><i class="fa fa-star-o fa-stack-1x"></i></span>{% endif %}
{% endfor %} <a href="" onclick="$('a[href=\'#tab-review\']').trigger('click'); return false;">{{ reviews }}</a> / <a href="" onclick="$('a[href=\'#tab-review\']').trigger('click'); return false;">{{ text_write }}</a></p>
<hr>
{% for rating in expanded_rating %}
<p>1 - {{ rating.one }}%</p>
<p>2 - {{ rating.two }}%</p>
<p>3 - {{ rating.three }}%</p>
<p>4 - {{ rating.four }}%</p>
<p>5 - {{ rating.five }}%</p>
<h3>Общий рейтинг - {{ rating.rating }}</h3>
<p>На основании {{ rating.total }} отзывов</p>
{% endfor %}
<hr>
для продукта есть обязательное поле Артикул.
Смотрел в admin/controller но там ничего!
validateForm()
из контроллера admin/controller/catalog/product.php
закомментируйте эти строки:if ((utf8_strlen($this->request->post['model']) < 1) || (utf8_strlen($this->request->post['model']) > 64)) {
$this->error['model'] = $this->language->get('error_model');
}
admin/view/template/catalog/recurring_form.twig
<div class="form-group required">
<label class="col-sm-2 control-label" for="input-model">{{ entry_model }}</label>
<div class="col-sm-10">
<input type="text" name="model" value="{{ model }}" placeholder="{{ entry_model }}" id="input-model" class="form-control"/>
{% if error_model %}
<div class="text-danger">{{ error_model }}</div>
{% endif %}</div>
</div>