Post 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? :-[


Posts

Joined
Sat Nov 01, 2014 12:18 pm

Post 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

For Friendly Professional Support - Click Here


User avatar

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post 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?


Posts

Joined
Sat Nov 01, 2014 12:18 pm

Post 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

For Friendly Professional Support - Click Here


User avatar

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post 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


Posts

Joined
Sat Nov 01, 2014 12:18 pm
Who is online

Users browsing this forum: No registered users and 51 guests