/** * Do the points transfer for the review * * @param Mage_Review_Model_Review $review * @param int $rule : Special Rule * @return boolean : whether or not the point-transfer succeeded */ public function transferReviewPoints($review, $rule) { $num_points = $rule->getPointsAmount(); $currency_id = $rule->getPointsCurrencyId(); $review_id = $review->getId(); $rule_id = $rule->getId(); $transfer = $this->initTransfer($num_points, $currency_id, $rule_id); $customer_id = $review->getCustomerId(); if (!$transfer) { return false; } // get the default starting status - usually Pending if (!$transfer->setStatus(null, Mage::helper('rewards/config')->getInitialTransferStatusAfterReview())) { // we tried to use an invalid status... is getInitialTransferStatusAfterReview() improper ?? return false; } $transfer->setReviewId($review_id)->setComments(Mage::getStoreConfig('rewards/transferComments/reviewOrRatingEarned'))->setCustomerId($customer_id)->save(); return true; }
/** * set review data * * @param Mage_Review_Model_Review $review $product * * @return $this */ public function setReviewData(Mage_Review_Model_Review $review) { $store = Mage::app()->getStore($review->getStoreId()); $websiteName = $store->getWebsite()->getName(); $storeName = $store->getName(); $this->setId($review->getReviewId())->setWebsiteName($websiteName)->setStoreName($storeName)->setReviewDate($review->getCreatedAt())->setCustomerId($review->getCustomerId())->setEmail($review->getEmail()); return $this; }
/** * Prepare data for review insert * * @todo validate data * @param Mage_Review_Model_Review $review * @return array */ protected function _prepareInsertData(Mage_Review_Model_Review $review) { $data = array('base' => array('entity_id' => $review->getEntityId(), 'entity_pk_value' => $review->getEntityPkValue(), 'status_id' => $review->getStatusId()), 'detail' => array('title' => strip_tags($review->getTitle()), 'detail' => strip_tags($review->getDetail()), 'store_id' => $review->getStoreId(), 'customer_id' => $review->getCustomerId(), 'nickname' => strip_tags($review->getNickname()))); if ($review->hasData('stores') && is_array($review->getStores())) { $stores = $review->getStores(); $stores[] = 0; $data['stores'] = $stores; } elseif ($review->hasData('stores')) { $data['stores'] = array(); } return $data; }