Google+

Pages

Friday, June 22, 2012

Magento: How to delete test orders in magento

To delete test order from magento:
  1. Login to Admin Panel and go to Sales-->Orders.
  2. Note down your test order ids, for example: 100000001,100000002,100000003,100000111,100000112,100000199
  3. Now create a php file in magento root directory and name it: deleteOrders.php
  4. Now copy below code and paste it in your file:


    <?php
    require 'app/Mage.php';
    Mage::app('admin')->setUseSessionInUrl(false);                                                                                                                 //replace your own orders numbers here:
    $test_order_ids
    =array(
     
    '100000001',
     
    '100000002',
     
    '100000003',
     
    '100000109',
     
    '100000112',
     
    '100000134'
    );
    foreach($test_order_ids as $id){
       
    try{
           
    Mage::getModel('sales/order')->loadByIncrementId($id)->delete();
            echo
    "order #".$id." is removed".PHP_EOL;
       
    }catch(Exception $e){
            echo
    "order #".$id." could not be remvoved: ".$e->getMessage().PHP_EOL;
       
    }
    }
    echo
    "complete."
     ?>
     
  5. Now go to your browsers address bar and run file from here like:
    [Your_Magento_Base_URL] /deleteOrders.php


  6. At the end, delete deleteOrders.php.

    That's All.. Cheers :)

2 comments:

Unknown said...

Sorry It will show again in sales order list of admin...But if we click on this it will showing error like "This order no longer exists."
I have to delete that list also

Ple help me

Anonymous said...

Same problem for me also :(