{% include('@CustomerReview42/Block/customer_review4_recommend_css.twig') %}
{% import('@CustomerReview42/Block/customer_review4_recommend_macro.twig') as recommend_macro %}
{% if pagination.totalItemCount > 0 %}
{% for Product in pagination %}
{% set review_list = repository('Plugin\\CustomerReview42\\Entity\\CustomerReviewTotal').getRecommend(Product.id) %}
{% set reviewer_total = 0 %}
{% set review_total_point = 0 %}
{% set count = 5 %}
{% for i in review_list %}
{% set reviewer_total = reviewer_total + i %}
{% set review_total_point = review_total_point + i * count %}
{% set count = count - 1 %}
{% endfor %}
{% set review_point = reviewer_total == 0 ? 0 : (review_total_point / reviewer_total) %}
{% if 0 < reviewer_total %}
<div id="plg_customer_review{{Product.id}}" class="review-layoutRole product_list">
<h3 class="review_score" data-id="{{ Product.id }}" data-avg="{{ review_point }}" data-num="{{ reviewer_total }}" data-starsize="22" data-mstarsize="14" data-imgbase="{{ asset('aneros/img/products/') }}">
<span class="review_all_score_image" style="display: inline-block"></span>
<a href="{{ url('product_detail', {'id': Product.id}) }}#review_area"><span class="review_all_score"></span></a>
</h3>
</div>
{% endif %}
<script>
$(function () {
if ( $('#plg_customer_review_anchor{{Product.id}}').length) {
$('#plg_customer_review{{Product.id}}').insertAfter($('#plg_customer_review_anchor{{Product.id}}'));
} else if ( $('#productForm{{Product.id}}').length) {
$('#plg_customer_review{{Product.id}}').insertBefore($('#productForm{{Product.id}}'));
} else {
$('#plg_customer_review{{Product.id}}').hide();
}
});
</script>
{% endfor %}
{% endif %}