Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $rulesCollection = Mage::getModel('salesrule/rule')->getCollection();
- foreach($rulesCollection as $rule){
- $coupon = $rule->getCoupons();
- }
- $rules = Mage::getResourceModel('salesrule/rule_collection')->load();
- foreach ($rules as $rule) {
- $conditions = $rule->getConditionsSerialized();
- var_dump($conditions);
- }
- ?>
- {{block type="core/template" name="email_coupon" template="email/coupon.phtml"}}
- public function getAllActiveCoupon(){
- $coupontable = 'salesrule_coupon';
- $today = Mage::getModel('core/date')->date('Y-m-d');
- $select = $this->_read->select()
- ->from('salesrule', array('name', 'description'))
- ->joinLeft(
- array('sc' => $coupontable),
- "(sc.rule_id = salesrule.rule_id) AND (sc.expiration_date IS NULL OR sc.expiration_date >= '{$today}')",
- array('code'))
- ->where('is_active = ?', 1)
- ->where('from_date IS NULL OR from_date <= ?', $today)
- ->where('to_date IS NULL OR to_date >= ?', $today)
- ->where('is_rss = ?', 1);
- $result = $this->_read->fetchAll($select); //fetch all active couopon
- return $result;
- }
- in view file
- $coupons = $this->getActiveCoupon();
- <?php
- if (!empty($coupons)) :
- foreach ($coupons as $coupon):
- ?>
- <li>
- <h2><?php echo $coupon['name']; ?></h2>
- <p><?php echo $coupon['description']; ?> </p>
- </li>
- <?php endforeach; ?>
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement