Jump to content

Suppression anciennes commandes sur Prestashop 1.6


Recommended Posts

Bonjour,

Je cherche un moyen de supprimer d'anciennes commandes suivant un critère défini sur un Prestashop 1.6 (par exemple les commandes datant d'il y a plus de deux ans).

J'anticipe les réponses, je sais qu'il est illégal en France de supprimer des commandes, mais ces dernières ont été importées dans un logiciel de gestion commerciale.. Il y a actuellement plusieurs dizaines de milliers de commandes sur le site en question.

Si vous avez des solutions (module, requetes ou autres), je suis preneuse :)

Merci d'avance pour vos réponses et bonne journée

Link to comment
Share on other sites

DELETE FROM ps_order_carrier WHERE date_add < '2020-06-16';
DELETE ps_order_detail_tax FROM ps_order_detail_tax LEFT JOIN ps_order_detail ON ps_order_detail.id_order_detail = ps_order_detail_tax.id_order_detail LEFT JOIN ps_orders ON ps_order_detail.id_order = ps_orders.id_order WHERE ps_orders.date_add < '2020-06-16';
DELETE ps_order_detail FROM ps_order_detail LEFT JOIN ps_orders ON ps_order_detail.id_order = ps_orders.id_order WHERE ps_orders.date_add < '2020-06-16';
DELETE FROM ps_order_history WHERE date_add < '2020-06-16';
DELETE ps_order_invoice_payment FROM ps_order_invoice_payment LEFT JOIN ps_order_invoice ON ps_order_invoice.id_order_invoice = ps_order_invoice_payment.id_order_invoice WHERE date_add < '2020-06-16';
DELETE ps_order_invoice_tax FROM ps_order_invoice_tax LEFT JOIN ps_order_invoice ON ps_order_invoice.id_order_invoice = ps_order_invoice_tax.id_order_invoice WHERE date_add < '2020-06-16';
DELETE FROM ps_order_invoice WHERE date_add < '2020-06-16';
DELETE FROM ps_order_payment WHERE date_add < '2020-06-16';
DELETE FROM ps_orders WHERE date_add < '2020-06-16';

Je vous conseille d'utiliser "SELECT *" au lieu de "DELETE x FROM" afin de vérifier ce qui va être supprimé.
Vous pouvez modifier la date. J'ai mis 2 ans à partir d'aujourd'hui. Il se peut qu'il y ait d'autres tables à vider, mais j'ai mis les principales.

Link to comment
Share on other sites

  • 3 weeks later...
On 6/16/2022 at 11:30 AM, Tom Girou said:
DELETE FROM ps_order_carrier WHERE date_add < '2020-06-16';
DELETE ps_order_detail_tax FROM ps_order_detail_tax LEFT JOIN ps_order_detail ON ps_order_detail.id_order_detail = ps_order_detail_tax.id_order_detail LEFT JOIN ps_orders ON ps_order_detail.id_order = ps_orders.id_order WHERE ps_orders.date_add < '2020-06-16';
DELETE ps_order_detail FROM ps_order_detail LEFT JOIN ps_orders ON ps_order_detail.id_order = ps_orders.id_order WHERE ps_orders.date_add < '2020-06-16';
DELETE FROM ps_order_history WHERE date_add < '2020-06-16';
DELETE ps_order_invoice_payment FROM ps_order_invoice_payment LEFT JOIN ps_order_invoice ON ps_order_invoice.id_order_invoice = ps_order_invoice_payment.id_order_invoice WHERE date_add < '2020-06-16';
DELETE ps_order_invoice_tax FROM ps_order_invoice_tax LEFT JOIN ps_order_invoice ON ps_order_invoice.id_order_invoice = ps_order_invoice_tax.id_order_invoice WHERE date_add < '2020-06-16';
DELETE FROM ps_order_invoice WHERE date_add < '2020-06-16';
DELETE FROM ps_order_payment WHERE date_add < '2020-06-16';
DELETE FROM ps_orders WHERE date_add < '2020-06-16';

Je vous conseille d'utiliser "SELECT *" au lieu de "DELETE x FROM" afin de vérifier ce qui va être supprimé.
Vous pouvez modifier la date. J'ai mis 2 ans à partir d'aujourd'hui. Il se peut qu'il y ait d'autres tables à vider, mais j'ai mis les principales.

Bonjour,

J'ai enfin pris le temps d'exécuter les commandes, tout est ok ! Encore merci :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...