Exemplo n.º 1
0
 /**
  * @param CouponSaving $couponSaving
  * @return array
  */
 public function getNumberOfProductsOrderdForSavingCoupon(CouponSaving $couponSaving, $customerId)
 {
     //	couponId=$couponSaving->getCouponSavingId();
     $query = "SELECT  COUNT(*) number_of_products_ordered, co_sa.required_number_of_products , max(st.prices) maxPaid\n            FROM coupon_saving co_sa, stamp st\n            WHERE co_sa.coupon_saving_id=st.coupon_saving_id\n            AND customer ={$customerId}  AND\n            co_sa.coupon_saving_id=" . $couponSaving->getCouponSavingId();
     Mage::log("query voor max paid {$query} ", null, 'custom.log');
     $results = $this->readConnection->fetchAll($query);
     $foundData;
     foreach ($results as $savingCouponData) {
         $requiredNumberOfProducts = $savingCouponData['required_number_of_products'];
         $numberOfProductsOrdered = $savingCouponData['number_of_products_ordered'];
         $maxPaid = $savingCouponData['maxPaid'];
         Mage::log("requiredNumberOfProducts {$requiredNumberOfProducts} ", null, 'custom.log');
         Mage::log(" numberOfProductsOrdered {$numberOfProductsOrdered}", null, 'custom.log');
         Mage::log(" numberOfProductsOrdered {$numberOfProductsOrdered}", null, 'custom.log');
         $foundData = array($requiredNumberOfProducts, $numberOfProductsOrdered, $maxPaid);
         break;
     }
     return $foundData;
 }