Exemplo n.º 1
0
 /**
  * Retrieve review data as xml object
  *
  * @param Mage_Review_Model_Review $review
  * @param string $itemNodeName
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function reviewToXmlObject(Mage_Review_Model_Review $review, $itemNodeName = 'item')
 {
     $rating = 0;
     /** @var $item Mage_XmlConnect_Model_Simplexml_Element */
     $item = Mage::getModel('xmlconnect/simplexml_element', '<' . $itemNodeName . '></' . $itemNodeName . '>');
     if ($review->getId()) {
         $item->addChild('review_id', $review->getId());
         $item->addChild('created_at', $this->formatDate($review->getCreatedAt()));
         $item->addChild('title', $item->escapeXml($review->getTitle()));
         $item->addChild('nickname', $item->escapeXml($review->getNickname()));
         $detail = $item->escapeXml($review->getDetail());
         if ($itemNodeName == 'item') {
             $remainder = '';
             $deviceType = Mage::helper('xmlconnect')->getDeviceType();
             if ($deviceType != Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPAD) {
                 $detail = Mage::helper('core/string')->truncate($detail, self::REVIEW_DETAIL_TRUNCATE_LEN, '', $remainder, false);
             }
         }
         $item->addChild('detail', $detail);
         $summary = Mage::getModel('rating/rating')->getReviewSummary($review->getId());
         if ($summary->getCount() > 0) {
             $rating = round($summary->getSum() / $summary->getCount() / 10);
         }
         if ($rating) {
             $item->addChild('rating_votes', $rating);
         }
     }
     return $item;
 }
Exemplo n.º 2
0
 /**
  * @param Mage_Review_Model_Review $review
  * @return string
  */
 public function getDate($review)
 {
     $date = $review->getCreatedAt();
     if (!empty($date)) {
         $date = date('c', strtotime($date));
     }
     return $date;
 }
Exemplo n.º 3
0
 /**
  * set text for the review
  */
 public function setDate()
 {
     parent::setDate(date('Y-m-d', strtotime($this->item->getCreatedAt())));
 }
 /**
  * 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;
 }