Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <?php
  2. $rulesCollection = Mage::getModel('salesrule/rule')->getCollection();
  3. foreach($rulesCollection as $rule){
  4. $coupon = $rule->getCoupons();
  5. }
  6.  
  7. $rules = Mage::getResourceModel('salesrule/rule_collection')->load();
  8.  
  9. foreach ($rules as $rule) {
  10. $conditions = $rule->getConditionsSerialized();
  11. var_dump($conditions);
  12. }
  13. ?>
  14.  
  15. {{block type="core/template" name="email_coupon" template="email/coupon.phtml"}}
  16.  
  17. public function getAllActiveCoupon(){
  18.  
  19. $coupontable = 'salesrule_coupon';
  20. $today = Mage::getModel('core/date')->date('Y-m-d');
  21. $select = $this->_read->select()
  22. ->from('salesrule', array('name', 'description'))
  23. ->joinLeft(
  24. array('sc' => $coupontable),
  25. "(sc.rule_id = salesrule.rule_id) AND (sc.expiration_date IS NULL OR sc.expiration_date >= '{$today}')",
  26. array('code'))
  27.  
  28. ->where('is_active = ?', 1)
  29. ->where('from_date IS NULL OR from_date <= ?', $today)
  30. ->where('to_date IS NULL OR to_date >= ?', $today)
  31. ->where('is_rss = ?', 1);
  32.  
  33. $result = $this->_read->fetchAll($select); //fetch all active couopon
  34. return $result;
  35. }
  36.  
  37. in view file
  38.  
  39. $coupons = $this->getActiveCoupon();
  40. <?php
  41. if (!empty($coupons)) :
  42. foreach ($coupons as $coupon):
  43. ?>
  44. <li>
  45. <h2><?php echo $coupon['name']; ?></h2>
  46. <p><?php echo $coupon['description']; ?> </p>
  47. </li>
  48. <?php endforeach; ?>
  49. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement