I need to show all coupons codes in cms page. For this i have created a custom phtml in templete and in this template i have wrote the following code :

$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();

and add a block in cms page :

{{block type="core/template" name="email_coupon" template="email/coupon.phtml"}}

But nothing is showing please help me .

  • what is the issue in code ,please explain
    – Amit Bera
    Apr 15, 2015 at 13:02

1 Answer 1


instead of load whole collection i suggest you use sql query with help of my custom function

  public function getAllActiveCoupon(){

        $coupontable = 'salesrule_coupon';
        $today = Mage::getModel('core/date')->date('Y-m-d');
        $select = $this->_read->select()
                ->from('salesrule', array('name', 'description'))
                        array('sc' => $coupontable),
                        "(sc.rule_id = salesrule.rule_id) AND (sc.expiration_date IS NULL OR sc.expiration_date >= '{$today}')",

                ->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();
        if (!empty($coupons)) :
            foreach ($coupons as $coupon):
                    <h2><?php echo $coupon['name']; ?></h2>
                    <p><?php echo $coupon['description']; ?> </p>
<?php endforeach; ?>    
<?php endif; ?>    

you can change condition depends on requirement

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.