-
-
Save sirakoff/b200d2048a483c6cdbc6043cbd6874b6 to your computer and use it in GitHub Desktop.
Revisions
-
vikramacharya created this gist
Aug 4, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ <?php //Initialize Mage Object require_once 'app/Mage.php'; Mage::app(); //Code to create coupon $couponCode='COUPONCODE'; //couponcode $rule = Mage::getModel('salesrule/rule'); //initialize salesrule $customer_groups = array(0,1); // Add customer group here $rule->setName('Name of coupon') ->setDescription('description of coupon') ->setFromDate('2017-07-01') ->setToDate('2017-12-12') ->setCouponType(2) //type of coupon ->setCouponCode($couponCode) ->setUsesPerCustomer(1) ->setUsesPerCoupon(100) ->setCustomerGroupIds($customer_groups) ->setIsActive(1) ->setConditionsSerialized('') ->setActionsSerialized('') ->setStopRulesProcessing(0) ->setIsAdvanced(1) ->setSortOrder(0) ->setSimpleAction('cart_fixed') //fixed amount discount on whole cart ->setDiscountAmount('100') //discount amount ->setDiscountQty(null) ->setDiscountStep(0) ->setSimpleFreeShipping('0') ->setApplyToShipping('0') ->setIsRss(0) ->setWebsiteIds(array(1)); $rule->save();