Jump to content

How to add product review rating stars to category pages?


ajensen27

Recommended Posts

  • 3 weeks later...

Vekia:

 

Yes. I just uninstalled and then re-installed the Product Comments module.

 

I also deleted the class_index.php file within the cache directory, as per Nemo.

 

I still can't get it to work!

 

I'm wondering, have you, or anyone else, had experience with the Google Rich Snippets + Product Ratings and Reviews module? I'm wondering if that would work better, plus there's some nice features as well.

 

I also went into myPHP database and noticed that the ProductInList hook doesn't even appear. What would make a hook not appear in the database?

Link to comment
Share on other sites

  • 2 weeks later...

it really gets down to comfort level and how much time you have.

 

if you are running a serious business and need to get stuff done...and move on...then it's best to get a pro module to accomplish the task.

 

If you want to become a developer...you can use examples given around the web and learn from them.  I personally don't do these sorts of 'how to's' because there are a multitude of different ps versions and user experience...i.e. telling a user to load this override and then delete such and such....is well...for some that follow the guide...a disaster and a time eater.

Link to comment
Share on other sites

Nemo's tutorial lacks concept and are overdosed with explanation which nobody has anything to do..

I dont care gimme another warning.

 

I speak facts

 

Hi Jiten Rash,

 

  If you want, you can always make your own tutorial and share it with the Community. I'm sure everybody would appreciate the time and effort you take to help out other merchants, much like Nemo1 does. 

Link to comment
Share on other sites

So jgullstr, if that portion of my product-list.tpl file appears like this currently:

 

<h3><a class="product_link" href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'|truncate:35:'...'}</a></h3>
 {hook h='productInList' idproduct=$product.id_product}

 

Where would I put the {rating id=$product.id_product} line?

 

Oh...do I also need to download and install your categorylistratings module?

Edited by rgwhitaker (see edit history)
Link to comment
Share on other sites

Hi rgwhitaker,

- As a last try, can you provide a link to the site and make sure you tried to either add nemo's solution or that you added the lines of code following jgullstr's module solution? Then we can see if there's anything wrong with the code, or that it sneakily uses a different tpl file or so. (If you don't want to share your URL (yet), please PM it to me)

 

Also check:

Did you  (TEMPORARILY!!): 

- turn OFF your smarty cache and

- 'Template cache' set to "Recompile templates if the files have been updated"

in Advanced Parameters->Performance

to see the changes take effect? Otherwise it won't work.

(Don't forget to turn cache back ON afterwards!)

 

pascal

Link to comment
Share on other sites

Tried to make a module of this while experimenting with smarty. Try it out and see if it works.

 

Instruction after install:

Add {rating id=$product.id_product} to your product-list.tpl.

 

Please post this under free modules.  We can then move the conversation to 'on topic'.  Post the link to the 'free module' post here.

 

Thanks for your contribution.

Link to comment
Share on other sites

  • 3 years later...

Hello,

It has been impossible for me to make the module working on my prestashop version (1.6.1.6)

I follow these two combined tutorials:
        http://nemops.com/prestashop-product-rating-product-list/#.WHYJKZLWFE4
        http://sobreprestashop.blogspot.com.es/2015/03/mostrar-calificacion-productos-en-lista-productos-prestashop.html

It has worked well on my prestashop version.
I only had to make a small change on productcomments.php to have the right counting of the number of reviews (Original code Spanish Tutorial):

    I change:  $this->context->smarty->assign('nbComments', (int)ProductComment::getCommentNumber($id_product));

    To:        $this->smarty->assign(array(
                            'nbComments' => (int) ProductComment::getCommentNumber($id_product),
                    ));


My complete function in productcomments.php is: 
// Product Stars On Product List  
public function hookProductInList($params)
 {
     require_once(dirname(__FILE__).'/ProductComment.php');
     require_once(dirname(__FILE__).'/ProductCommentCriterion.php');
     $id_product = $params['idproduct'];
     $product_average = 0;
     $grades = ProductComment::getAveragesByProduct($id_product, $this->context->language->id);
     $criterions = ProductCommentCriterion::getByProduct($id_product, $this->context->language->id);
     $grade_total = 0;
  if (count($grades) > 0)
  {
      foreach ($criterions as $criterion)
      {
          if (isset($grades[$criterion['id_product_comment_criterion']]))
          {
              $grade_total += (float)($grades[$criterion['id_product_comment_criterion']]);
          }
      }
      $product_average = $grade_total / count($criterions);         
      $this->context->smarty->assign('average_total', (int)$product_average);
                       
// Obtener el número de comentarios
      $this->smarty->assign(array(
                'nbComments' => (int) ProductComment::getCommentNumber($id_product),
        ));               
      return $this->display(__FILE__, '/product-list-rating.tpl');
  }
 }
// End Of Product Stars On Product List

 

Also for all people who have the cart button disappearing when you click on «read reviews» on product page, the solution is there:
https://github.com/PrestaShop/PrestaShop/pull/5280/files

Basically you have to modify: themes/YOUR THEME/js/product.js

Find the line: $(window).bind('hashchange', function(){

Change:
checkUrl();
findCombination();

To:
var is_combination = checkUrl();
if (is_combination)
findCombination();

It has worked like a charm for me on my prestashop version (1.6.1.6)
Hope it can help.
Regards

Link to comment
Share on other sites

  • 6 months later...

Hi,

 

When I activate the Block Layered Prestashop module, I am getting the following error :

PHP Fatal error:  Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/product-list.tpl"  on line 105 "{rating id=$product.id_product}" unknown tag "rating"

 

The line 105 is : 

{rating id=$product.id_product}

If I delete the line 105, the stars are not displayed on the product list page.

 

Would you know where is the Syntax Error is the line 105 ?

 

Thank you in advance for any help.

 

Patrick

Edited by patrmich (see edit history)
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
×
×
  • Create New...