Mage_Reports_Model_Mysql4_Review_Product_Collection Class Reference

Inheritance diagram for Mage_Reports_Model_Mysql4_Review_Product_Collection:

Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection Mage_Catalog_Model_Resource_Eav_Mysql4_Collection_Abstract Mage_Eav_Model_Entity_Collection_Abstract Varien_Data_Collection_Db Varien_Data_Collection

List of all members.

Public Member Functions

 joinReview ()
 addAttributeToSort ($attribute, $dir='asc')


Detailed Description

Definition at line 35 of file Collection.php.


Member Function Documentation

addAttributeToSort ( attribute,
dir = 'asc' 
)

Add attribute to sort order

Parameters:
string $attribute
string $dir
Returns:
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection

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     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:37 2009 for Magento by  doxygen 1.5.8