Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Как можно вывести надпись Отзывов: 3 в сетке товаров


Recommended Posts

Вывести-то не сложно...

1. Добавляем языковую переменную: в /catalog/language/russian/product/category.php добавляем строку

$_['text_product_reviews']	  = 'Отзывов: %s';
2. Пишем обработчик для языковой переменной, чтобы был вывод к-ва отзывов. В в /catalog/controller/product/category.php находим (где-то в середине файла):

$this->data['products'][] = array(
	 'product_id'  => $result['product_id'],
	 'thumb'	   => $image,
	 'name'		=> $result['name'],
	 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
	 'price'	   => $price,
	 'special'	 => $special,
	 'tax'		 => $tax,
	 'rating'	  => $result['rating'],
	 'reviews'	 => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
	 'href'		=> $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'])
	);
и меняем на:

$this->data['products'][] = array(
	 'product_id'  => $result['product_id'],
	 'thumb'	   => $image,
	 'name'		=> $result['name'],
	 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
	 'price'	   => $price,
	 'special'	 => $special,
	 'tax'		 => $tax,
	 'rating'	  => $result['rating'],
	 'reviews'	 => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
	 'product_reviews'	 => sprintf($this->language->get('text_product_reviews'), (int)$result['reviews']),
	 'href'		=> $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'])
	);
Т.е. добавилась строчка:
'product_reviews'	 => sprintf($this->language->get('text_product_reviews'), (int)$result['reviews']),
3. Добавляем надпись "Отзывов: 3" в сетку. В product/category.tpl вашего шаблона вставляем в нужное место
<div><a href="<?php echo $product['href']; ?>"><?php echo $product['product_reviews']; ?></a></div>

Все...

К данному диву можно написать свой класс в стилях, соответствующий вашему дизайну по аналогии с классом wishlist

Единственное, ссылка ведет на страницу с продуктом, как открыть сразу отзывы - не знаю...

  • +1 2
Link to comment
Share on other sites


Пользуйтесь на здоровье...

Только 1-й пункт надо будет добавить во все языки, чтобы если сайт мультиязычный не выдавало ошибки при переключении на другой язык...

Link to comment
Share on other sites


чтот не получилось вывести в модуле рекомендуем

надпись вывелась, но показывает всегда 0 отзывов

и сверху сайта появилась надпись

Notice: Undefined variable: result in /home/virtwww/w_front-cam_05a39bdb/http/catalog/controller/module/featured.php on line 61 - (их столько, сколько товаров)

Link to comment
Share on other sites

Решил сам

Изменил строку

'product_reviews'	    => sprintf($this->language->get('text_product_reviews'), (int)$result['reviews']),

на

'product_reviews'	    => sprintf($this->language->get('text_product_reviews'), (int)$product_info['reviews']),

в файле /catalog/controller/module/featured.php

	    $this->data['products'][] = array(
	  'product_id' => $product_info['product_id'],
	  'thumb'	  => $image,
	  'name'	   => $product_info['name'],
	  'price'	  => $price,
	  'special'    => $special,
	  'rating'	 => $rating,
	  'reviews'    => sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
	  'href'	   => $this->url->link('product/product', 'product_id=' . $product_info['product_id']),
	  'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
	  'product_reviews'	    => sprintf($this->language->get('text_product_reviews'), (int)$product_info['reviews']),

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.