Mage_Reports_Model_Mysql4_Product_Downloads_Collection Class Reference

Inheritance diagram for Mage_Reports_Model_Mysql4_Product_Downloads_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

 addSummary ()
 setOrder ($attribute, $dir='desc')
 addFieldToFilter ($field, $condition=null)

Protected Attributes

 $_idFieldName = 'link_id'


Detailed Description

Definition at line 35 of file Collection.php.


Member Function Documentation

addFieldToFilter ( field,
condition = null 
)

Add filtering

Returns:
Mage_Reports_Model_Mysql4_Product_Downloads_Collection

Reimplemented from Mage_Eav_Model_Entity_Collection_Abstract.

Definition at line 91 of file Collection.php.

00092     {
00093         if ($field == 'link_title') {
00094             $conditionSql = $this->_getConditionSql('l.title', $condition);
00095             $this->getSelect()->where($conditionSql);
00096         } else {
00097             parent::addFieldToFilter($field, $condition);
00098         }
00099         return $this;
00100     }

addSummary (  ) 

Add downloads summary grouping by product

Returns:
Mage_Reports_Model_Mysql4_Product_Downloads_Collection

Definition at line 44 of file Collection.php.

00045     {
00046         $this->getSelect()
00047             ->joinInner(
00048                 array('d' => $this->getTable('downloadable/link_purchased_item')),
00049                 'e.entity_id=d.product_id',
00050                 array(
00051                     'purchases' => 'd.number_of_downloads_bought',
00052                     'downloads' => 'd.number_of_downloads_used'
00053                 )
00054             )
00055             ->joinInner(
00056                 array('l' => $this->getTable('downloadable/link_title')),
00057                 'd.link_id=l.link_id',
00058                 array('l.link_id')
00059             )
00060             ->joinLeft(
00061                 array('l_store' => $this->getTable('downloadable/link_title')),
00062                 $this->getConnection()->quoteInto('l.link_id=l_store.link_id AND l_store.store_id=?',$this->getStoreId()),
00063                 array('link_title' => 'IFNULL(l_store.title, l.title)')
00064             )
00065             ->where('d.number_of_downloads_bought>0 OR d.number_of_downloads_used>0')
00066             ->group('d.link_id');
00067 
00068         return $this;
00069     }

setOrder ( attribute,
dir = 'desc' 
)

Add sorting

Returns:
Mage_Reports_Model_Mysql4_Product_Downloads_Collection

Reimplemented from Mage_Eav_Model_Entity_Collection_Abstract.

Definition at line 76 of file Collection.php.

00077     {
00078         if ($attribute == 'purchases' || $attribute == 'downloads' || $attribute == 'link_title') {
00079             $this->getSelect()->order($attribute . ' ' . $dir);
00080         } else {
00081             parent::setOrder($attribute, $dir);
00082         }
00083         return $this;
00084     }


Member Data Documentation

$_idFieldName = 'link_id' [protected]

Reimplemented from Varien_Data_Collection_Db.

Definition at line 37 of file Collection.php.


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