Mage_Review_Model_Review Class Reference

Inheritance diagram for Mage_Review_Model_Review:

Mage_Core_Model_Abstract Varien_Object

List of all members.

Public Member Functions

 getProductCollection ()
 getStatusCollection ()
 getTotalReviews ($entityPkValue, $approvedOnly=false, $storeId=0)
 aggregate ()
 getEntitySummary ($product, $storeId=0)
 getPendingStatus ()
 getReviewUrl ()
 validate ()
 appendSummary ($collection)

Public Attributes

const ENTITY_PRODUCT = 1
const STATUS_APPROVED = 1
const STATUS_PENDING = 2
const STATUS_NOT_APPROVED = 3

Protected Member Functions

 _construct ()
 _beforeDelete ()


Detailed Description

Definition at line 34 of file Review.php.


Member Function Documentation

_beforeDelete (  )  [protected]

Processing object before delete data

Returns:
Mage_Core_Model_Abstract

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 145 of file Review.php.

00146     {
00147         $this->_protectFromNonAdmin();
00148         return parent::_beforeDelete();
00149     }

_construct (  )  [protected]

Enter description here...

Reimplemented from Varien_Object.

Definition at line 42 of file Review.php.

00043     {
00044         $this->_init('review/review');
00045     }

aggregate (  ) 

Definition at line 62 of file Review.php.

00063     {
00064         $this->getResource()->aggregate($this);
00065         return $this;
00066     }

appendSummary ( collection  ) 

Append review summary to product collection

Parameters:
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
Returns:
Mage_Review_Model_Review

Definition at line 118 of file Review.php.

00119     {
00120         $entityIds = array();
00121         foreach ($collection->getItems() as $_itemId => $_item) {
00122             $entityIds[] = $_item->getEntityId();
00123         }
00124 
00125         if (sizeof($entityIds) == 0) {
00126             return $this;
00127         }
00128 
00129         $summaryData = Mage::getResourceModel('review/review_summary_collection')
00130             ->addEntityFilter($entityIds)
00131             ->addStoreFilter(Mage::app()->getStore()->getId())
00132             ->load();
00133 
00134         foreach ($collection->getItems() as $_item ) {
00135             foreach ($summaryData as $_summary) {
00136                 if ($_summary->getEntityPkValue() == $_item->getEntityId()) {
00137                     $_item->setRatingSummary($_summary);
00138                 }
00139             }
00140         }
00141 
00142         return $this;
00143     }

getEntitySummary ( product,
storeId = 0 
)

Definition at line 68 of file Review.php.

00069     {
00070         $summaryData = Mage::getModel('review/review_summary')
00071             ->setStoreId($storeId)
00072             ->load($product->getId());
00073         $summary = new Varien_Object();
00074         $summary->setData($summaryData->getData());
00075         $product->setRatingSummary($summary);
00076     }

getPendingStatus (  ) 

Definition at line 78 of file Review.php.

00079     {
00080         return self::STATUS_PENDING;
00081     }

getProductCollection (  ) 

Definition at line 47 of file Review.php.

00048     {
00049         return Mage::getResourceModel('review/review_product_collection');
00050     }

getReviewUrl (  ) 

Definition at line 83 of file Review.php.

00084     {
00085         return Mage::getUrl('review/product/view', array('id' => $this->getReviewId()));
00086     }

getStatusCollection (  ) 

Definition at line 52 of file Review.php.

00053     {
00054         return Mage::getResourceModel('review/review_status_collection');
00055     }

getTotalReviews ( entityPkValue,
approvedOnly = false,
storeId = 0 
)

Definition at line 57 of file Review.php.

00058     {
00059         return $this->getResource()->getTotalReviews($entityPkValue, $approvedOnly, $storeId);
00060     }

validate (  ) 

Definition at line 88 of file Review.php.

00089     {
00090         $errors = array();
00091 
00092         $helper = Mage::helper('customer');
00093 
00094         if (!Zend_Validate::is($this->getTitle(), 'NotEmpty')) {
00095             $errors[] = $helper->__('Review summary can\'t be empty');
00096         }
00097 
00098         if (!Zend_Validate::is($this->getNickname(), 'NotEmpty')) {
00099             $errors[] = $helper->__('Nickname can\'t be empty');
00100         }
00101 
00102         if (!Zend_Validate::is($this->getDetail(), 'NotEmpty')) {
00103             $errors[] = $helper->__('Review can\'t be empty');
00104         }
00105 
00106         if (empty($errors)) {
00107             return true;
00108         }
00109         return $errors;
00110     }


Member Data Documentation

const ENTITY_PRODUCT = 1

Definition at line 36 of file Review.php.

const STATUS_APPROVED = 1

Definition at line 38 of file Review.php.

Definition at line 40 of file Review.php.

const STATUS_PENDING = 2

Definition at line 39 of file Review.php.


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

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