Exemplo n.º 1
0
 /**
  * Fetch rate customer group and website
  *
  * @param Enterprise_Reward_Model_Reward_Rate $rate
  * @param integer $customerId
  * @param integer $websiteId
  * @return Enterprise_Reward_Model_Mysql4_Reward_Rate
  */
 public function fetch(Enterprise_Reward_Model_Reward_Rate $rate, $customerGroupId, $websiteId, $direction)
 {
     $select = $this->_getReadAdapter()->select()->from($this->getMainTable())->where('website_id IN (?, 0)', (int) $websiteId)->where('customer_group_id IN (?, 0)', $customerGroupId)->where('direction = ?', $direction)->order('customer_group_id DESC')->order('website_id DESC')->limit(1);
     if ($row = $this->_getReadAdapter()->fetchRow($select)) {
         $rate->addData($row);
     }
     $this->_afterLoad($rate);
     return $this;
 }
 /**
  * Fetch rate customer group and website
  *
  * @param Enterprise_Reward_Model_Reward_Rate $rate
  * @param int $customerGroupId
  * @param int $websiteId
  * @param int $direction
  * @return Enterprise_Reward_Model_Resource_Reward_Rate
  */
 public function fetch(Enterprise_Reward_Model_Reward_Rate $rate, $customerGroupId, $websiteId, $direction)
 {
     $select = $this->_getReadAdapter()->select()->from($this->getMainTable())->where('website_id IN (:website_id, 0)')->where('customer_group_id IN (:customer_group_id, 0)')->where('direction = :direction')->order('customer_group_id DESC')->order('website_id DESC')->limit(1);
     $bind = array(':website_id' => (int) $websiteId, ':customer_group_id' => (int) $customerGroupId, ':direction' => $direction);
     $row = $this->_getReadAdapter()->fetchRow($select, $bind);
     if ($row) {
         $rate->addData($row);
     }
     $this->_afterLoad($rate);
     return $this;
 }