How to Get Auto-Generated Coupon Codes in Magento 1.9

magento-1.9shopping-cart-price-rules

I want to list all the shopping cart rules that are set with auto-generate coupon code options in admin,

what model i should use? and what are the conditions?

Best Answer

protected function getAutoGenerateCouponRules()
{
    $rules = Mage::getResourceModel('salesrule/rule_collection');
    $autoGenerateCouponRules = array();
    foreach ($rules as $rule) {
        if ($rule->getIsActive()) {
            if($rule->getUseAutoGeneration() == 1){
                $autoGenerateCouponRules[] = array('id' => $rule->getRuleId(), 'name' => $rule->getName());
            }
        }
    }
    return $autoGenerateCouponRules;
}
Related Topic