Public Member Functions | |
joinReview () | |
addAttributeToSort ($attribute, $dir='asc') |
Definition at line 35 of file Collection.php.
addAttributeToSort | ( | $ | attribute, | |
$ | dir = 'asc' | |||
) |
Add attribute to sort order
string | $attribute | |
string | $dir |
Distinct we are using for remove duplicates of products which have several rows in price index (like grouped products)
Reimplemented from Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection.
Definition at line 62 of file Collection.php.
00063 { 00064 if (in_array($attribute, array('review_cnt', 'last_created', 'avg_rating', 'avg_rating_approved'))) { 00065 $this->getSelect()->order($attribute.' '.$dir); 00066 return $this; 00067 } 00068 00069 return parent::addAttributeToSort($attribute, $dir); 00070 }
joinReview | ( | ) |
Definition at line 37 of file Collection.php.
00038 { 00039 $this->addAttributeToSelect('name'); 00040 $this->getSelect()->join( 00041 array('r' => $this->getTable('review/review')), 00042 'e.entity_id=r.entity_pk_value', 00043 array( 00044 'review_cnt' => 'COUNT(DISTINCT r.review_id)', 00045 'last_created' => 'MAX(r.created_at)', 00046 ) 00047 ); 00048 00049 $this->getSelect()->joinLeft( 00050 array('table_rating' => $this->getTable('rating_option_vote_aggregated')), 00051 'e.entity_id=table_rating.entity_pk_value AND table_rating.store_id>0', 00052 array( 00053 'avg_rating' => 'SUM(table_rating.percent)/COUNT(table_rating.rating_id)', 00054 'avg_rating_approved' => 'SUM(table_rating.percent_approved)/COUNT(table_rating.rating_id)' 00055 ) 00056 ); 00057 $this->getSelect()->group('e.entity_id'); 00058 00059 return $this; 00060 }