In the previous post we updated script to add coupons using a CSV with a fixed percentage and a one time usage.
In this script that we build we remove all the coupons that were initially imported. This is great if you just want to start clean again with a magento installation without any coupons.
Here is the deal to remove all coupons in your Magento system
Just upload this script to your website and call it via your browser. Note that the 20procent is the name of the coupons in your admin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<?php // Delete all the coupons ini_set('auto_detect_line_endings', true); // Allows Mage require 'app/Mage.php'; Mage::app(); //Initializes Mage Mage::app('default'); deleteCoupon(); function deleteCoupon() { $collection = Mage::getModel('salesrule/rule')->getCollection()->load(); foreach($collection as $model) { // Delete all new newsletter sub coupons if ($model->getName() == '20procent') { //Delete all coupons expiring today // if($model->getToDate() == date('Y-m-d')){ $model->delete(); echo "Deleted <br />"; } else { echo "No coupons found! <br />"; } } } |