Public Member Functions | |
__construct () | |
addCustomerFilter ($customerId) | |
addStoreFilter ($storeId) | |
addStoreData () | |
addEntityFilter ($entity, $pkValue) | |
addEntityInfo ($entityName) | |
addStatusFilter ($status) | |
setDateOrder ($dir='DESC') | |
addRateVotes () | |
addReviewsTotalCount () | |
load ($printQuery=false, $logQuery=false) | |
Protected Member Functions | |
_addStoreData () | |
Protected Attributes | |
$_reviewTable | |
$_reviewDetailTable | |
$_reviewStatusTable | |
$_reviewEntityTable | |
$_reviewStoreTable | |
$_addStoreDataFlag = false |
Definition at line 34 of file Collection.php.
__construct | ( | ) |
Reimplemented from Varien_Data_Collection.
Definition at line 43 of file Collection.php.
00044 { 00045 $resources = Mage::getSingleton('core/resource'); 00046 00047 parent::__construct($resources->getConnection('review_read')); 00048 00049 $this->_reviewTable = $resources->getTableName('review/review'); 00050 $this->_reviewDetailTable = $resources->getTableName('review/review_detail'); 00051 $this->_reviewStatusTable = $resources->getTableName('review/review_status'); 00052 $this->_reviewEntityTable = $resources->getTableName('review/review_entity'); 00053 $this->_reviewStoreTable = $resources->getTableName('review/review_store'); 00054 00055 $this->_select->from(array('main_table'=>$this->_reviewTable)) 00056 ->join(array('detail'=>$this->_reviewDetailTable), 'main_table.review_id=detail.review_id'); 00057 00058 $this->setItemObjectClass(Mage::getConfig()->getModelClassName('review/review')); 00059 }
_addStoreData | ( | ) | [protected] |
Definition at line 199 of file Collection.php.
00200 { 00201 $reviewsIds = $this->getColumnValues('review_id'); 00202 $storesToReviews = array(); 00203 if (count($reviewsIds)>0) { 00204 $select = $this->getConnection()->select() 00205 ->from($this->_reviewStoreTable) 00206 ->where('review_id IN(?)', $reviewsIds); 00207 $result = $this->getConnection()->fetchAll($select); 00208 foreach ($result as $row) { 00209 if (!isset($storesToReviews[$row['review_id']])) { 00210 $storesToReviews[$row['review_id']] = array(); 00211 } 00212 $storesToReviews[$row['review_id']][] = $row['store_id']; 00213 } 00214 } 00215 00216 foreach ($this as $item) { 00217 if(isset($storesToReviews[$item->getId()])) { 00218 $item->setStores($storesToReviews[$item->getId()]); 00219 } else { 00220 $item->setStores(array()); 00221 } 00222 } 00223 }
addCustomerFilter | ( | $ | customerId | ) |
Definition at line 61 of file Collection.php.
00062 { 00063 $this->addFilter('customer', 00064 $this->getConnection()->quoteInto('detail.customer_id=?', $customerId), 00065 'string'); 00066 return $this; 00067 }
addEntityFilter | ( | $ | entity, | |
$ | pkValue | |||
) |
Add entity filter
int|string | $entity | |
int | $pkValue |
Definition at line 101 of file Collection.php.
00102 { 00103 if (is_numeric($entity)) { 00104 $this->addFilter('entity', 00105 $this->getConnection()->quoteInto('main_table.entity_id=?', $entity), 00106 'string'); 00107 } 00108 elseif (is_string($entity)) { 00109 $this->_select->join($this->_reviewEntityTable, 00110 'main_table.entity_id='.$this->_reviewEntityTable.'.entity_id'); 00111 00112 $this->addFilter('entity', 00113 $this->getConnection()->quoteInto($this->_reviewEntityTable.'.entity_code=?', $entity), 00114 'string'); 00115 } 00116 00117 $this->addFilter('entity_pk_value', 00118 $this->getConnection()->quoteInto('main_table.entity_pk_value=?', $pkValue), 00119 'string'); 00120 00121 return $this; 00122 }
addEntityInfo | ( | $ | entityName | ) |
addRateVotes | ( | ) |
Definition at line 160 of file Collection.php.
00161 { 00162 foreach( $this->getItems() as $item ) { 00163 $votesCollection = Mage::getModel('rating/rating_option_vote') 00164 ->getResourceCollection() 00165 ->setReviewFilter($item->getId()) 00166 ->setStoreFilter(Mage::app()->getStore()->getId()) 00167 ->addRatingInfo(Mage::app()->getStore()->getId()) 00168 ->load(); 00169 $item->setRatingVotes( $votesCollection ); 00170 } 00171 00172 return $this; 00173 }
addReviewsTotalCount | ( | ) |
Definition at line 175 of file Collection.php.
00176 { 00177 $this->_select->joinLeft(array('r' => $this->_reviewTable), 'main_table.entity_pk_value = r.entity_pk_value', 'COUNT(r.review_id) as total_reviews'); 00178 $this->_select->group('main_table.review_id'); 00179 00180 return $this; 00181 }
addStatusFilter | ( | $ | status | ) |
Add status filter
int|string | $status |
Definition at line 136 of file Collection.php.
00137 { 00138 if (is_numeric($status)) { 00139 $this->addFilter('status', 00140 $this->getConnection()->quoteInto('main_table.status_id=?', $status), 00141 'string'); 00142 } 00143 elseif (is_string($status)) { 00144 $this->_select->join($this->_reviewStatusTable, 00145 'main_table.status_id='.$this->_reviewStatusTable.'.status_id'); 00146 00147 $this->addFilter('status', 00148 $this->getConnection()->quoteInto($this->_reviewStatusTable.'.status_code=?', $status), 00149 'string'); 00150 } 00151 return $this; 00152 }
addStoreData | ( | ) |
Add stores data
int | $storeId |
Definition at line 88 of file Collection.php.
addStoreFilter | ( | $ | storeId | ) |
Add store filter
int|array | $storeId |
Definition at line 75 of file Collection.php.
00076 { 00077 $this->getSelect()->join(array('store'=>$this->_reviewStoreTable), 'main_table.review_id=store.review_id', array()); 00078 $this->getSelect()->where('store.store_id IN (?)', $storeId); 00079 return $this; 00080 }
load | ( | $ | printQuery = false , |
|
$ | logQuery = false | |||
) |
Load data
Reimplemented from Varien_Data_Collection_Db.
Definition at line 183 of file Collection.php.
00184 { 00185 if ($this->isLoaded()) { 00186 return $this; 00187 } 00188 Mage::dispatchEvent('review_review_collection_load_before', array('collection' => $this)); 00189 parent::load($printQuery, $logQuery); 00190 if($this->_addStoreDataFlag) { 00191 $this->_addStoreData(); 00192 } 00193 00194 00195 00196 return $this; 00197 }
setDateOrder | ( | $ | dir = 'DESC' |
) |
Definition at line 154 of file Collection.php.
00155 { 00156 $this->setOrder('main_table.created_at', $dir); 00157 return $this; 00158 }
$_addStoreDataFlag = false [protected] |
Definition at line 41 of file Collection.php.
$_reviewDetailTable [protected] |
Definition at line 37 of file Collection.php.
$_reviewEntityTable [protected] |
Definition at line 39 of file Collection.php.
$_reviewStatusTable [protected] |
Definition at line 38 of file Collection.php.
$_reviewStoreTable [protected] |
Definition at line 40 of file Collection.php.
$_reviewTable [protected] |
Definition at line 36 of file Collection.php.