A2 Hosting
General support for technical problems with OpenCart v1.x
5 posts Page 1 of 1
by xiaoluojava1 » Sat Nov 01, 2014 12:31 pm
I've looking for the way that show product reviews count in homepage opencart about 3 days, but no one can help me. Though there are some extensions for that but must be paid, i only want to call for product reviews in my opencart homepage.

I found my product page can show the sum of reviews, and the code is below:
Code: Select all
<?php echo $reviews; ?>


then i tried to call for this function on my homepage, insert the above code into product_module.tpl
(plus: homepage has also called for product_module.tpl) but it said:

Code: Select all
Notice: Undefined variable: reviews in 
\catalog\view\theme\mystore\template\module\product_module.tpl on line 94


I only want to show the reviews count, so difficult, who can help me? :-[
by uksitebuilder » Sat Nov 01, 2014 8:46 pm
in your module controller, you will need to add something like

Code: Select all
$this->load->model('catalog/product');
$reviews = $this->catalog_model_getProduct($product_id)->row['reviews'];
$reviews = ($reviews == '' ? 0 : $reviews);
ImageImageImageImageImage
ImageImageImageImageImageImageImageImageImageImage
by xiaoluojava1 » Sun Nov 02, 2014 12:01 am
uksitebuilder wrote: in your module controller, you will need to add something like

Code: Select all
$this->load->model('catalog/product');
$reviews = $this->catalog_model_getProduct($product_id)->row['reviews'];
$reviews = ($reviews == '' ? 0 : $reviews);


thx for your reply, but i want to know in which module controller?
by uksitebuilder » Sun Nov 02, 2014 2:07 am
I was assuming you were using a custom module as you had put product_module.tpl

In which part of the home page would you want to put the count of reviews for each product

or are you just wanting to pt a total count of al reviews for all products ?
ImageImageImageImageImage
ImageImageImageImageImageImageImageImageImageImage
by xiaoluojava1 » Sun Nov 02, 2014 12:02 pm
yeah, i'm using a custom module product_module.tpl in homepage, the product_module.tpl located in catalog/view/theme/mytemplate/template/module/product_module.tpl

i've tried insert your code as above into product_module.tpl, there are too many mistakes...

Well, i just want to show single product reviews count after star rating, not all products reviews' count, like the Amazon homepage below:
Image
5 posts Page 1 of 1
Who is online

Users browsing this forum: No registered users and 36 guests

A2 Hosting