Пример #1
0
 /**
  * 
  * @param TBT_Rewardssocial_Model_Facebook_Like $fb_like_model
  * 
  * @return TBT_Rewardssocial_Model_Mysql4_Facebook_Like_Transfer_Collection 
  */
 public function addFacebookLikeFilter($fb_like_model)
 {
     $ref_collection = Mage::getModel('rewards/transfer_reference')->getCollection()->addFilter('reference_type', TBT_Rewardssocial_Model_Facebook_Like_Reference::REFERENCE_TYPE_ID)->addFilter('reference_id', $fb_like_model->getId());
     $transfer_ids = $ref_collection->getColumnValues('rewards_transfer_id');
     $this->addFieldToFilter('main_table.rewards_transfer_id', array('IN' => $transfer_ids));
     $this->addFilter('customer_id', $fb_like_model->getCustomerId());
     return $this;
 }
Пример #2
0
 /**
  * Goes through an already validated rule collection and transfers rule points to the customer specified
  * with the like model as the reference.
  * @param array(TBT_Rewards_Model_Special) $ruleCollection
  * @param TBT_Rewards_Model_Customer $customer
  * @param TBT_Rewardssocial_Model_Facebook_Like $like_model
  * @note: Adds messages to the session TODO: return messages instead of adding session messages
  */
 protected function _transferLikePoints($ruleCollection, $customer, $like_model)
 {
     foreach ($ruleCollection as $rule) {
         if (!$rule->getId()) {
             continue;
         }
         try {
             $transfer = Mage::getModel('rewardssocial/facebook_like_transfer');
             $is_transfer_successful = $transfer->createFacebookLikePoints($customer, $like_model->getId(), $rule);
             if ($is_transfer_successful) {
                 $points_for_liking = Mage::getModel('rewards/points')->set($rule);
                 Mage::getSingleton('core/session')->addSuccess(Mage::helper('rewardssocial')->__('You received <b>%s</b> for liking this page on Facebook.', $points_for_liking));
             }
         } catch (Exception $ex) {
             Mage::logException($ex);
             Mage::getSingleton('core/session')->addError($ex->getMessage());
         }
     }
     return $this;
 }