1

I need nulling/zero/ reset order history. For example, New Order # 100000001 (BUT NOT # 10000023)

Preferably without the use MyPHPadmin. Maybe my problem can be solved through SSH commands or by using the module from Magento Connect? Maybe there are ways to move the database to another server without order history?

Please help, any advice and suggestions Thanks

  • You realize that you don't need phpMyAdmin for anything if you have SSH access? $ mysql -uUSER -pPASSWORD DATABASE and there you go. – Fabian Schmengler Feb 13 '15 at 21:52
2

I'm using two free modules to do this.
First I delete all test orders using this one:
ASPerience DeleteOrders
I spent a lot of time checking out all the free extensions available, even inspecting the source code, and this one deletes related data too, if you enable this feature in the config (Invoices, etc…).

Second, to really answer your question:
This free module can reset or change Order and Invoice numbers per store:
Custom Invoice And Order Numbers
If the "Change" button of this extension does nothing, then read my comment on this extension on its Magento Connect page. Set the desired number minus 1.

1

You can make a custom module, in that create a setup file and run this sql query inside it,

SET FOREIGN_KEY_CHECKS=0;

TRUNCATE `sales_payment_transaction`;
TRUNCATE `sales_flat_creditmemo`;
TRUNCATE `sales_flat_creditmemo_comment`;
TRUNCATE `sales_flat_creditmemo_grid`;
TRUNCATE `sales_flat_creditmemo_item`;
TRUNCATE `sales_flat_order`;
TRUNCATE `sales_flat_order_address`;
TRUNCATE `sales_flat_order_grid`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sales_flat_order_status_history`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_order_payment`;
TRUNCATE `sales_flat_quote_payment`;
TRUNCATE `sales_flat_quote_shipping_rate`;
TRUNCATE `sales_flat_shipment`;
TRUNCATE `sales_flat_shipment_item`;
TRUNCATE `sales_flat_shipment_grid`;
TRUNCATE `sales_flat_shipment_track`;
TRUNCATE `sales_flat_invoice`;
TRUNCATE `sales_flat_invoice_grid`;
TRUNCATE `sales_flat_invoice_item`;
TRUNCATE `sales_flat_invoice_comment`;

This is assuming you know how to create a custom module and a db setup file.

1

The above will reset ALL order history including the # 10000023 that I think you dont wanto to delete.

If so you have to change the above sintax from "TRUNCATE " to "DELETE ... FROM != order_id_to_save"

start from the # 10000023 (check in admin the order_id is different from the order_increment_id) and look for the appropriate foreing key of the above table.

1

Here is some code that can delete the order comments for a single order. You can integrate this in a controller or model and use it when needed.

$orderId = '100000001';
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
$comments = $order->getAllStatusHistory();
foreach ($comments as $comment) {
    $comment->delete();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.