Call-back icon  Sales: Call 877.832.5289 (N America)|310.295.4144 (International)

Magento

eCommerce Software for Online Growth

Magento Forum

   
Sort By Rating
 
CSPalmisano
Member
 
Total Posts:  64
Joined:  2008-05-31
 

How can my modify the front end to allow users to sort products by rating?

I have searched all over for this solution with no luck.

 
Magento Community Magento Community
Magento Community
Magento Community
 
CSPalmisano
Member
 
Total Posts:  64
Joined:  2008-05-31
 

puh-leeease help!

 
Magento Community Magento Community
Magento Community
Magento Community
 
CSPalmisano
Member
 
Total Posts:  64
Joined:  2008-05-31
 

Somebody has GOT to know how to do this

 
Magento Community Magento Community
Magento Community
Magento Community
 
CSPalmisano
Member
 
Total Posts:  64
Joined:  2008-05-31
 

I’ll name my next kid after you if you help. Really, I will.

 
Magento Community Magento Community
Magento Community
Magento Community
 
CSPalmisano
Member
 
Total Posts:  64
Joined:  2008-05-31
 

Is it possible that nobody knows how to do this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Garrone
Sr. Member
 
Avatar
Total Posts:  102
Joined:  2007-11-03
Lauria
 

I’m interested too.

 Signature 

La Compagnia del Cavatappi, Prodotti Tipici, vini e Vendita Vini.
Se cerchi un Agriturismo in Italia visita Vacanze in Agriturismo.

 
Magento Community Magento Community
Magento Community
Magento Community
 
joesixpack
Member
 
Total Posts:  35
Joined:  2008-06-23
 

Well, this is not a solution but a starting point:

/app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php

At line 38 you should find this:

protected function _construct()
{
parent::_construct();
$this->_availableOrder = array(
‘position’ => $this->__(’Best Value’),
‘price’ => $this->__(’Price’),
‘name’ => $this->__(’Name’)
);

To sort by SKU and remove “Best Value” the following worked:

protected function _construct()
{
parent::_construct();
$this->_availableOrder = array(
//’position’ => $this->__(’Best Value’),
‘price’ => $this->__(’Price’),
‘sku’ => $this->__(’Manufacturer-SKU’),
‘name’ => $this->__(’Name’)
);

(I am using Manufacturer-SKU in the drop down because my SKUs all start with the manufacture’s name.)

Numerical star ratings are being retrieved with product info, so there should be a way to sort by rating. I tried:

protected function _construct()
{
parent::_construct();
$this->_availableOrder = array(
//’position’ => $this->__(’Best Value’),
‘price’ => $this->__(’Price’),
‘sku’ => $this->__(’Manufacturer-SKU’),
‘RatingSummary’ => $this->__(’Rating’),
‘name’ => $this->__(’Name’)
);

No errors, but I don’t know if it works because I am unable to turn the rating system on. Not sure if RatingSummary is the right field. Does anyone know what “Best Value” (position) means? Could that be the rating summary? If so, then sort by rating is already available. I am wondering what the default secondary sort is.

 
Magento Community Magento Community
Magento Community
Magento Community
 
joesixpack
Member
 
Total Posts:  35
Joined:  2008-06-23
 

Comparing the code in /app/design/frontend/default/default/template/catalog/product/list.phtml:

<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php endif; ?>

to the output in the demo store:

<div class="ratings">
<div class="rating-box">
<div class="rating" style="width:77%"></div>
</div>
(4)
</div>

it looks as if RatingSummary might include two items: average rating (77%) and number of ratings (4).

But the sort might still work if RatingSummary is a string like “77,4”

Can someone who has star ratings working try this?

Controlling the default sort direction is yet another issue

 
Magento Community Magento Community
Magento Community
Magento Community
 
insight
Jr. Member
 
Total Posts:  29
Joined:  2008-07-24
 

joe six pack you are a champion this really helped me out

 Signature 

I’m advertising bic surfboards for a client!!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
jvalen
Member
 
Avatar
Total Posts:  54
Joined:  2007-12-12
Los Angeles
 

I’m trying to figure out a way to sort by price. Any ideas?

 Signature 

Converting to Magento
BarbieIsOut

 
Magento Community Magento Community
Magento Community
Magento Community
 
joesixpack
Member
 
Total Posts:  35
Joined:  2008-06-23
 

Umm, it already has a sort by price in the drop down. If you want it to default to sort by price, try putting price first in the array:

protected function _construct()
{
parent::_construct();
$this->_availableOrder = array(
‘price’ => $this->__(’Price’),
‘position’ => $this->__(’Best Value’),
‘name’ => $this->__(’Name’)
);

 
Magento Community Magento Community
Magento Community
Magento Community
 
joyously
Guru
 
Total Posts:  350
Joined:  2008-08-21
 

I was looking in the code for something else, and saw that the Product object has a field called rating_summary, so I changed it like this:

protected function _construct()
{
parent::_construct();
$this->_availableOrder = array(
‘name’ => $this->__(’Name’),
‘price’ => $this->__(’Price’),
// ‘position’ => $this->__(’Best Value’)
‘rating_summary’ => $this->__(’Rating’)
);

It didn’t give any errors, and it sorted differently than when I choose Name. I tried to add some ratings to make sure it was working, but somehow the ratings table isn’t printed out when I click on Review Product. I get the review part, but not the rating part. Looking in the template (app/design/frontend/default/YOURNAME/template/review/form.phtml) I see this check before printing the box of rating stars

if( $this->getRatings() && $this->getRatings()->getSize())

I have the initial set of ratings (which I think is the things the votes are counted for like Price, Quality, Value), so I don’t see why it’s not printing.
Anybody have any ideas?
UPDATE:
I got the ratings to show up. They have a visibility field that either got changed to unselected when I edited the name or it never defaulted to my one store. Anyway, once the visibility is set, I could enter a star rating with the review on a product. I did and tried the sort, but it did not sort that one product to the top (or bottom...I clicked on the arrow and nothing changed).

 
Magento Community Magento Community
Magento Community
Magento Community
 
MAGNETO.ME
Jr. Member
 
Total Posts:  2
Joined:  2008-09-09
 
jvalen - 28 August 2008 06:43 AM

I’m trying to figure out a way to sort by price. Any ideas?

in template/catalog/product/list/toolbar.phtml , before the select box add this :

<?php 
                    $available_orders 
= array('price'=>$this->__('Price'));
                    
$this->setAvailableOrders($available_orders);
?>

 
Magento Community Magento Community
Magento Community
Magento Community
 
ExactRail
Jr. Member
 
Total Posts:  2
Joined:  2008-08-28
 
MAGNETO.ME - 19 September 2008 01:52 AM

jvalen - 28 August 2008 06:43 AM
I’m trying to figure out a way to sort by price. Any ideas?

in template/catalog/product/list/toolbar.phtml , before the select box add this :

<?php 
                    $available_orders 
= array('price'=>$this->__('Price'));
                    
$this->setAvailableOrders($available_orders);
?>

Best option yet. Can be accomplished by applying this change to a copy of the file in your own custom theme. E.g. app/design/frontend/[theme-base]/[theme]/template/catalog/product/list/toolbar.phtml

This allows for simple upgrades without having to return and reapply the change.

 
Magento Community Magento Community
Magento Community
Magento Community
 
joyously
Guru
 
Total Posts:  350
Joined:  2008-08-21
 
joyously - 01 September 2008 06:35 PM

I was looking in the code for something else, and saw that the Product object has a field called rating_summary, so I changed it like this:

protected function _construct()
{
parent::_construct();
$this->_availableOrder = array(
‘name’ => $this->__(’Name’),
‘price’ => $this->__(’Price’),
// ‘position’ => $this->__(’Best Value’)
‘rating_summary’ => $this->__(’Rating’)
);

It didn’t give any errors, and it sorted differently than when I choose Name.

Again looking at something totally different, I saw that I was on the right track for this except that rating_summary is an array, so it won’t sort that correctly. If someone can figure out how to indicate an element of rating_summary, it might work. Here’s what I was reading when I found this tidbit: http://activecodeline.com/show-products-on-sale-in-magento/

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
Sales: Call 877.832.5289 (North America) 310.295.4144 (International)
© Copyright 2008 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
52261 users|831 users currently online|105548 forum posts