Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
How do I delete test orders? 
 
macsmart
Jr. Member
 
Total Posts:  29
Joined:  2007-08-31
Greensboro, NC
 

Is there an easy way to delete orders from the system? I’ve made a number of test orders while familiarizing myself with the system, and need to clear them out before a proof-of-concept demo I’m doing for a client. Any help would be greatly appreciated.

Thanks and Go Go Magento!

-mf

 
Magento Community Magento Community
Magento Community
Magento Community
 
brandondrew
Member
 
Avatar
Total Posts:  64
Joined:  2007-09-12
 

Yes, I need to do this too.  Yoav?  Moshe?  Could you outline how to do this?  If the simple answer is “go into the database and delete records” could you tell us how to make sure we don’t leave the db in an inconsistent state?  Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikkstocks
Member
 
Total Posts:  47
Joined:  2008-06-08
 

bump, me too smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dustin
Sr. Member
 
Total Posts:  160
Joined:  2008-03-13
Columbus, OH
 

There is no easy way to delete orders from the admin backend.

There is an ongoing discussion on this issue here: http://www.magentocommerce.com/boards/viewthread/1680/P0/

There is a workaround to delete all the orders but it does require you to modify the db directly.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikkstocks
Member
 
Total Posts:  47
Joined:  2008-06-08
 

yep, i found the workaround though i did feel the urge to backup the entire database first as it wasnt nice!. but all seemed to have run smoothly…

basically open up phpmyadmin or similar, and delete all records containing the order number of the order you want to delete. Leaves stuff behind in the sales history, but if you then delete all the items contained in the orders (from the backend) the leftover bits disappear (you can then recreate the items)

 
Magento Community Magento Community
Magento Community
Magento Community
 
brandondrew
Member
 
Avatar
Total Posts:  64
Joined:  2007-09-12
 

OK, I deleted the contents of this post, because (after going away from the computer and coming back to it and to this thread) I responded, and only afterward realized I has forgotten to check the link above, which looks like it answers all… Thanks Moshe!

 
Magento Community Magento Community
Magento Community
Magento Community
 
leetaylordoes
Sr. Member
 
Total Posts:  227
Joined:  2008-02-05
San Diego, CA
 

Hi All,

Sorry for the late response to this, but I’m just now seeing this discussion.

Please feel free to visit this link for direct instructions and an easy script download for you to use: http://eliasinteractive.com/blog/magento-ecommerce-how-to-reset-all-test-order-information-and-set-unique-prefix-for-orders-invoices-shipments-and-credit-memos/

Cheers =)
Lee Taylor

 
Magento Community Magento Community
Magento Community
Magento Community
 
davidgrun
Sr. Member
 
Total Posts:  245
Joined:  2008-07-10
 

@timothyleetaylor

Thanks! your script worked great on my 1.1.8! With multiple websites and stores.

 
Magento Community Magento Community
Magento Community
Magento Community
 
sideshow_bob
Jr. Member
 
Total Posts:  3
Joined:  2009-02-05
 

Hi Lee,

Thanks a lot for this script, it worked fine in 1.3.1 with one store.

Bob

 
Magento Community Magento Community
Magento Community
Magento Community
 
camilo sanchez
Jr. Member
 
Total Posts:  13
Joined:  2008-11-21
Dominican Republic
 

Hi!

Thanks a lot for this script, it worked great in 1.3.2.2 with one store!

Camilo Sánchez

 
Magento Community Magento Community
Magento Community
Magento Community
 
Matt Kammersell
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2007-09-21
Las Vegas, NV
 

And let’s say you don’t want to reset ALL your orders, maybe you want to PRUNE a production database.. if that’s the case, this php file (added to a crontab, or ran from your magento root directory) will DELETE all cancelled orders (5000 limit per instance).  This is helpful for production instances, to keep your magento running smoothly if you run alot of test transactions.

(Also attached)

<?php

require_once('app/Mage.php');
Mage::app('admin');
Mage::getSingleton("core/session", array("name" => "adminhtml"));
Mage::register('isSecureArea',true);
 
$collection Mage::getResourceModel('sales/order_collection')
            ->
addAttributeToSelect('*')
            ->
setPageSize(5000)           
            ->
addFieldToFilter('status''canceled')->load();

foreach (
$collection as $col{
  Mage
::log($col->getIncrementId() . ' order deleted ');
    try 
{
         $col
->delete();
    
catch (Exception $e{
        
throw $e;
    
}
}
File Attachments
c.php  (File Size: 1KB - Downloads: 165)
 
Magento Community Magento Community
Magento Community
Magento Community
 
CaratCache
Jr. Member
 
Total Posts:  9
Joined:  2009-06-08
 

I would be very cautious when using this script. There are a lot of connections to an order, that if not cleaned up properly, will cause you problems, problems that will not be easy to recover from.

 
Magento Community Magento Community
Magento Community
Magento Community
 
centerax
Sr. Member
 
Avatar
Total Posts:  90
Joined:  2008-09-10
Montevideo, Uruguay
 

Here is another way. http://inchoo.net/ecommerce/magento/delete-test-orders-in-magento/

 
Magento Community Magento Community
Magento Community
Magento Community
 
Modulesoft
Member
 
Avatar
Total Posts:  40
Joined:  2008-11-14
India
 

you can Easily Delete orders and manage all orders via Order book extension
check this out
http://www.magentocommerce.com/magento-connect/Modulesoft+Solutions/extension/4047/mspl_orderbook

 
Magento Community Magento Community
Magento Community
Magento Community
 
Modulesoft
Member
 
Avatar
Total Posts:  40
Joined:  2008-11-14
India
 

Ho to delete magento test orders and false orders.

Here is the solution:

Use magento orderbook to delete magento test orders or any false if you want. Look here : http://www.magentocommerce.com/magento-connect/Modulesoft+Solutions/extension/4047/mspl_orderbook

smile

enjoy

 
Magento Community Magento Community
Magento Community
Magento Community
 
mandurah
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2010-01-03
Mesa, AZ (USA)
 

Magnificant post zdhkw2010!

Worked perfectly - Thank you!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2