FOL9000

Magento: Alle Bestellungen löschen

von | 38 Kommentare

Auf Testsystemen häufen sich schnell Bestellungen an, die irgendwann stören. Besonders das Übertragen der Datenbank auf andere Systeme ist dann zwar noch möglich, aber man hat den Test-Müll dann auch auf dem neuen System. Weil Magento keine Funktion hat, um Bestellungen zu löschen, hilft das folgende Script: Es versetzt die Datenbank wieder in einen vorzeigbaren und brauchbaren Zustand.

Das kurze SQL-Script löscht den beim Testen anfallenden Bestellungs-Müll. Alles, was beim Testen so anfällt, was man aber nicht auf andere Systeme übertragen möchte, wird komplett entfernt. Danach dürfte die Datenbank in einem sauberen Zustand sein, sodass man ein Datenbank-Export problemlos auf einem anderen System einsetzen kann.

Die Datenbankstruktur von Magento ist nicht gerade einfach und zwischen den Versionen auch manchmal leicht unterschiedlich. Ich habs unter 1.7.0.2 ausprobiert und es funktionierte problemlos. Trotzdem: Anwendung auf eigene Gefahr, und vorher ein Backup machen! (Kleines Update: Auch unter 1.9.0.1 funktioniert es.)

Das Script setzt nicht den Counter für die Bestell-Nummern zurück. Hat man zehn Bestellungen gelöscht bekommt trotz des Löschens die nächste Bestellung die Nummer elf. Dies lässt sich mit Anweisungen zum Setzen des Increment-Counters lösen, die ich ebendort beschrieben habe.

Vor dem Ausführen muss natürlich noch im USE-Statement der richtige Datenbank-Name eingesetzt werden.

Und noch etwas: Obwohl der folgende SQL-Code an Einfachheit kaum zu überbieten sein dürfte: Er ist nicht von mir, ich weiß aber auch nicht mehr, woher er ist.

-- Reset Magento Test Data
-- Checked with 1.7.0.2
USE `magento_databse`;
SET FOREIGN_KEY_CHECKS=0;
-- reset dashboard search queries
TRUNCATE `catalogsearch_query`;
ALTER TABLE `catalogsearch_query` AUTO_INCREMENT=1;
-- reset sales order info
TRUNCATE `sales_flat_creditmemo`;
TRUNCATE `sales_flat_creditmemo_comment`;
TRUNCATE `sales_flat_creditmemo_grid`;
TRUNCATE `sales_flat_creditmemo_item`;
TRUNCATE `sales_flat_invoice`;
TRUNCATE `sales_flat_invoice_comment`;
TRUNCATE `sales_flat_invoice_grid`;
TRUNCATE `sales_flat_invoice_item`;
TRUNCATE `sales_flat_order`;
TRUNCATE `sales_flat_order_address`;
TRUNCATE `sales_flat_order_grid`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sales_flat_order_payment`;
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_quote_payment`;
TRUNCATE `sales_flat_quote_shipping_rate`;
TRUNCATE `sales_flat_shipment`;
TRUNCATE `sales_flat_shipment_comment`;
TRUNCATE `sales_flat_shipment_grid`;
TRUNCATE `sales_flat_shipment_item`;
TRUNCATE `sales_flat_shipment_track`;
TRUNCATE `sales_invoiced_aggregated`;
TRUNCATE `sales_invoiced_aggregated_order`;
TRUNCATE `sales_order_aggregated_created`;
TRUNCATE `sendfriend_log`;
TRUNCATE `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `wishlist`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;
ALTER TABLE `sales_flat_creditmemo` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_status_history` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_shipping_rate` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_track` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_aggregated_created` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;

38 Kommentare

  1. You have brought up a very good details , thankyou for the post.

  2. You have brought up a very good details , thankyou for the post.

  3. You have brought up a very good details , thankyou for the post.

  4. Very informative article post.Really looking forward to read more. Fantastic.

  5. Very informative article post.Really looking forward to read more. Fantastic.

  6. Very informative article post.Really looking forward to read more. Fantastic.

  7. Hey very nice website!! Man .. Beautiful .. Amazing .. I’ll bookmark your website and take the feeds alsoI’m happy to find numerous useful information here in the post, we need work out more techniques in this regard, thanks for sharing. . . . . .

  8. Hey very nice website!! Man .. Beautiful .. Amazing .. I’ll bookmark your website and take the feeds alsoI’m happy to find numerous useful information here in the post, we need work out more techniques in this regard, thanks for sharing. . . . . .

  9. Hey very nice website!! Man .. Beautiful .. Amazing .. I’ll bookmark your website and take the feeds alsoI’m happy to find numerous useful information here in the post, we need work out more techniques in this regard, thanks for sharing. . . . . .

  10. I like this post, enjoyed this one regards for posting. He removes the greatest ornament of friendship, who takes away from it respect. by Cicero.

  11. I like this post, enjoyed this one regards for posting. He removes the greatest ornament of friendship, who takes away from it respect. by Cicero.

  12. I like this post, enjoyed this one regards for posting. He removes the greatest ornament of friendship, who takes away from it respect. by Cicero.

  13. Hey, thanks for the blog article.Really looking forward to read more. Much obliged.

  14. Hey, thanks for the blog article.Really looking forward to read more. Much obliged.

  15. Beneficial Location Hi gentleman the following transpire a number of web page link with the aim of represses information that will a person may possibly acquire positive yourselves. The Significance Verifying away from home.

  16. Beneficial Location Hi gentleman the following transpire a number of web page link with the aim of represses information that will a person may possibly acquire positive yourselves. The Significance Verifying away from home.

  17. very nice post, i certainly love this web site, keep on it

  18. very nice post, i certainly love this web site, keep on it

  19. very nice post, i certainly love this web site, keep on it

  20. Great article post.Really thank you! Fantastic.

  21. Great article post.Really thank you! Fantastic.

  22. Great article post.Really thank you! Fantastic.

  23. In My Bambino site you can find sso many interesting aspefts

  24. In My Bambino site you can find sso many interesting aspefts

  25. In My Bambino site you can find sso many interesting aspefts

  26. I will immediately grab your rss feed as I can not find your email subscription link or enewsletter service. Do you’ve any? Please let me know in order that I could subscribe. Thanks.

  27. I will immediately grab your rss feed as I can not find your email subscription link or enewsletter service. Do you’ve any? Please let me know in order that I could subscribe. Thanks.

  28. I will immediately grab your rss feed as I can not find your email subscription link or enewsletter service. Do you’ve any? Please let me know in order that I could subscribe. Thanks.

  29. Hi, everything is going well here and ofcourse every one is sharing information, that’s really fine, keep up writing.

  30. Hi, everything is going well here and ofcourse every one is sharing information, that’s really fine, keep up writing.

  31. Hi, everything is going well here and ofcourse every one is sharing information, that’s really fine, keep up writing.

  32. Hello there! This post could not be written any better! Reading this post reminds me of my good old room mate! He always kept talking about this. I will forward this page to him. Fairly certain he will have a good read. Thank you for sharing!

  33. Hello there! This post could not be written any better! Reading this post reminds me of my good old room mate! He always kept talking about this. I will forward this page to him. Fairly certain he will have a good read. Thank you for sharing!

  34. Hello there! This post could not be written any better! Reading this post reminds me of my good old room mate! He always kept talking about this. I will forward this page to him. Fairly certain he will have a good read. Thank you for sharing!

  35. Hello there! This post could not be written any better! Reading this post reminds me of my good old room mate! He always kept talking about this. I will forward this page to him. Fairly certain he will have a good read. Thank you for sharing!

  36. Thanks so much for sharing all with the awesome info! I am looking forward to checking out far more posts!

  37. Thanks so much for sharing all with the awesome info! I am looking forward to checking out far more posts!

  38. Thanks so much for sharing all with the awesome info! I am looking forward to checking out far more posts!

Schreibe einen Kommentar

Pflichtfelder sind mit * markiert.