Mage_Reports_Model_Mysql4_Review_Customer_Collection Class Reference

Inheritance diagram for Mage_Reports_Model_Mysql4_Review_Customer_Collection:

Mage_Review_Model_Mysql4_Review_Collection Varien_Data_Collection_Db Varien_Data_Collection

List of all members.

Public Member Functions

 joinCustomers ()
 getSelectCountSql ()


Detailed Description

Definition at line 35 of file Collection.php.


Member Function Documentation

getSelectCountSql (  ) 

Get SQL for get record count

Returns:
Varien_Db_Select

Reimplemented from Varien_Data_Collection_Db.

Definition at line 78 of file Collection.php.

00079     {
00080         $countSelect = clone $this->_select;
00081         $countSelect->reset(Zend_Db_Select::ORDER);
00082         $countSelect->reset(Zend_Db_Select::GROUP);
00083         $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
00084         $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
00085 
00086         $sql = $countSelect->__toString();
00087 
00088         $sql = preg_replace('/^select\s+.+?\s+from\s+/is', 'select count(DISTINCT `detail`.`customer_id`) from ', $sql);
00089 
00090         return $sql;
00091     }

joinCustomers (  ) 

Definition at line 37 of file Collection.php.

00038     {
00039         $customer = Mage::getResourceSingleton('customer/customer');
00040         //TODO: add full name logic
00041         $firstnameAttr = $customer->getAttribute('firstname');
00042         $firstnameAttrId = $firstnameAttr->getAttributeId();
00043         $firstnameTable = $firstnameAttr->getBackend()->getTable();
00044 
00045         if ($firstnameAttr->getBackend()->isStatic()) {
00046             $firstnameField = 'firstname';
00047             $attrCondition = '';
00048         } else {
00049             $firstnameField = 'value';
00050             $attrCondition = ' AND _table_customer_firstname.attribute_id = '.$firstnameAttrId;
00051         }
00052 
00053         $this->getSelect()->joinInner(array('_table_customer_firstname' => $firstnameTable),
00054             '_table_customer_firstname.entity_id=detail.customer_id'.$attrCondition, array());
00055 
00056         $lastnameAttr = $customer->getAttribute('lastname');
00057         $lastnameAttrId = $lastnameAttr->getAttributeId();
00058         $lastnameTable = $lastnameAttr->getBackend()->getTable();
00059 
00060         if ($lastnameAttr->getBackend()->isStatic()) {
00061             $lastnameField = 'lastname';
00062             $attrCondition = '';
00063         } else {
00064             $lastnameField = 'value';
00065             $attrCondition = ' AND _table_customer_lastname.attribute_id = '.$lastnameAttrId;
00066         }
00067 
00068         $this->getSelect()->joinInner(array('_table_customer_lastname' => $lastnameTable),
00069             '_table_customer_lastname.entity_id=detail.customer_id'.$attrCondition, array())
00070             ->from("", array(
00071                         'customer_name' => "CONCAT(_table_customer_firstname.{$firstnameField}, ' ', _table_customer_lastname.{$lastnameField})",
00072                         'review_cnt' => "COUNT(main_table.review_id)"))
00073             ->group('detail.customer_id');
00074 
00075         return $this;
00076     }


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