Comment supprimer les ordres de test de Magento2
veuillez m'expliquer la bonne façon de supprimer les commandes de test sur le site Magento2.J'ai supprimé tous les enregistrements de la table 'sales_order' mais les commandes existent toujours dans le backend.
10
demandé sur
VIPIN A ROY
2016-06-16 16:41:55
6 réponses
testé à Magento 2.1.0
soyez prudent: faites une sauvegarde de votre sql en premier.
Utilisez le sql ci-dessous selon vos besoins :
SET FOREIGN_KEY_CHECKS=0;
# Clean order history
TRUNCATE TABLE `sales_bestsellers_aggregated_daily`;
TRUNCATE TABLE `sales_bestsellers_aggregated_monthly`;
TRUNCATE TABLE `sales_bestsellers_aggregated_yearly`;
# Clean order infos
TRUNCATE TABLE `sales_creditmemo`;
TRUNCATE TABLE `sales_creditmemo_comment`;
TRUNCATE TABLE `sales_creditmemo_grid`;
TRUNCATE TABLE `sales_creditmemo_item`;
TRUNCATE TABLE `sales_invoice`;
TRUNCATE TABLE `sales_invoiced_aggregated`;
TRUNCATE TABLE `sales_invoiced_aggregated_order`;
TRUNCATE TABLE `sales_invoice_comment`;
TRUNCATE TABLE `sales_invoice_grid`;
TRUNCATE TABLE `sales_invoice_item`;
TRUNCATE TABLE `sales_order`;
TRUNCATE TABLE `sales_order_address`;
TRUNCATE TABLE `sales_order_aggregated_created`;
TRUNCATE TABLE `sales_order_aggregated_updated`;
TRUNCATE TABLE `sales_order_grid`;
TRUNCATE TABLE `sales_order_item`;
TRUNCATE TABLE `sales_order_payment`;
TRUNCATE TABLE `sales_order_status_history`;
TRUNCATE TABLE `sales_order_tax`;
TRUNCATE TABLE `sales_order_tax_item`;
TRUNCATE TABLE `sales_payment_transaction`;
TRUNCATE TABLE `sales_refunded_aggregated`;
TRUNCATE TABLE `sales_refunded_aggregated_order`;
TRUNCATE TABLE `sales_shipment`;
TRUNCATE TABLE `sales_shipment_comment`;
TRUNCATE TABLE `sales_shipment_grid`;
TRUNCATE TABLE `sales_shipment_item`;
TRUNCATE TABLE `sales_shipment_track`;
TRUNCATE TABLE `sales_shipping_aggregated`;
TRUNCATE TABLE `sales_shipping_aggregated_order`;
# Clean cart infos
TRUNCATE TABLE `quote`;
TRUNCATE TABLE `quote_address`;
TRUNCATE TABLE `quote_address_item`;
TRUNCATE TABLE `quote_id_mask`;
TRUNCATE TABLE `quote_item`;
TRUNCATE TABLE `quote_item_option`;
TRUNCATE TABLE `quote_payment`;
TRUNCATE TABLE `quote_shipping_rate`;
# Reset indexes (if you want your orders number start back to 1
TRUNCATE TABLE sequence_invoice_1;
TRUNCATE TABLE sequence_order_1;
TRUNCATE TABLE sequence_shipment_1;
TRUNCATE TABLE sequence_creditmemo_1;
SET FOREIGN_KEY_CHECKS=1;
NE PAS TRONQUER / VIDER CE QUI SUIT:
- sales_order_status
- sales_sequence_meta
- sales_sequence_profile
- sales_order_status_label
- sales_order_status_state
30
répondu
user1171440
2016-09-09 15:41:47
Vous pouvez supprimer l'ordre par programmation:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Model\Order')->getCollection()
->addFieldToFilter('entity_id', (array) $orderIds);
foreach ($orders as $o) {
//load order object - I know it's not ok to use load in a loop but it
should be ok since it's a one time script
$order = Mage::getModel('sales/order')->load($o->getId());
//delete all order items
$items = $order->getAllItems();
foreach ($items as $item) {
$item->delete();
}
$invoices = $order->getInvoiceCollection();
foreach ($invoices as $invoice){
//delete all invoice items
$items = $invoice->getAllItems();
foreach ($items as $item) {
$item->delete();
}
//delete invoice
$invoice->delete();
}
$creditnotes = $order->getCreditmemosCollection();
foreach ($creditnotes as $creditnote){
//delete all creditnote items
$items = $creditnote->getAllItems();
foreach ($items as $item) {
$item->delete();
}
//delete credit note
$creditnote->delete();
}
$shipments = $order->getShipmentsCollection();
foreach ($shipments as $shipment){
//delete all shipment items
$items = $shipment->getAllItems();
foreach ($items as $item) {
$item->delete();
}
//delete shipment
$shipment->delete();
}
3
répondu
Vikas Dobariya
2017-09-27 12:03:38
SET FOREIGN_KEY_CHECKS=0;
# Clean order history
TRUNCATE TABLE `mg_sales_bestsellers_aggregated_daily`;
TRUNCATE TABLE `mg_sales_bestsellers_aggregated_monthly`;
TRUNCATE TABLE `mg_sales_bestsellers_aggregated_yearly`;
# Clean order infos
TRUNCATE TABLE `mg_sales_creditmemo`;
TRUNCATE TABLE `mg_sales_creditmemo_comment`;
TRUNCATE TABLE `mg_sales_creditmemo_grid`;
TRUNCATE TABLE `mg_sales_creditmemo_item`;
TRUNCATE TABLE `mg_sales_invoice`;
TRUNCATE TABLE `mg_sales_invoiced_aggregated`;
TRUNCATE TABLE `mg_sales_invoiced_aggregated_order`;
TRUNCATE TABLE `mg_sales_invoice_comment`;
TRUNCATE TABLE `mg_sales_invoice_grid`;
TRUNCATE TABLE `mg_sales_invoice_item`;
TRUNCATE TABLE `mg_sales_order`;
TRUNCATE TABLE `mg_sales_order_address`;
TRUNCATE TABLE `mg_sales_order_aggregated_created`;
TRUNCATE TABLE `mg_sales_order_aggregated_updated`;
TRUNCATE TABLE `mg_sales_order_grid`;
TRUNCATE TABLE `mg_sales_order_item`;
TRUNCATE TABLE `mg_sales_order_payment`;
TRUNCATE TABLE `mg_sales_order_status_history`;
TRUNCATE TABLE `mg_sales_order_tax`;
TRUNCATE TABLE `mg_sales_order_tax_item`;
TRUNCATE TABLE `mg_sales_payment_transaction`;
TRUNCATE TABLE `mg_sales_refunded_aggregated`;
TRUNCATE TABLE `mg_sales_refunded_aggregated_order`;
TRUNCATE TABLE `mg_sales_shipment`;
TRUNCATE TABLE `mg_sales_shipment_comment`;
TRUNCATE TABLE `mg_sales_shipment_grid`;
TRUNCATE TABLE `mg_sales_shipment_item`;
TRUNCATE TABLE `mg_sales_shipment_track`;
TRUNCATE TABLE `mg_sales_shipping_aggregated`;
TRUNCATE TABLE `mg_sales_shipping_aggregated_order`;
# Clean cart infos
TRUNCATE TABLE `mg_quote`;
TRUNCATE TABLE `mg_quote_address`;
TRUNCATE TABLE `mg_quote_address_item`;
TRUNCATE TABLE `mg_quote_id_mask`;
TRUNCATE TABLE `mg_quote_item`;
TRUNCATE TABLE `mg_quote_item_option`;
TRUNCATE TABLE `mg_quote_payment`;
TRUNCATE TABLE `mg_quote_shipping_rate`;
# Reset indexes (if you want your orders number start back to 1
TRUNCATE TABLE mg_sequence_invoice_1;
TRUNCATE TABLE mg_sequence_order_1;
TRUNCATE TABLE mg_sequence_shipment_1;
TRUNCATE TABLE mg_sequence_creditmemo_1;
SET FOREIGN_KEY_CHECKS=1;
0
répondu
VIVEK KUMAR KANAUJIA
2017-05-06 06:09:30
pourquoi ne pas utiliser cette simple extension disponible gratuitement pour Magento2 https://magecomp.com/magento-2-delete-orders.html
0
répondu
Gaurav Jain
2017-06-07 11:09:52
pour supprimer les ordres de test de Magento2 exécuter ci-dessous Requête Mysql :
TRUNCATE TABLE sales_order ;
TRUNCATE TABLE sales_order_grid ;
TRUNCATE TABLE sales_invoice ;
TRUNCATE TABLE sales_invoice_grid ;
TRUNCATE TABLE sales_creditmemo ;
TRUNCATE TABLE sales_creditmemo_grid ;
TRUNCATE TABLE sales_shipment ;
TRUNCATE TABLE sales_shipment_grid ;
-1
répondu
Emizen Tech
2016-06-17 07:08:03
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE TABLE sales_order ;
TRUNCATE TABLE sales_order_grid ;
TRUNCATE TABLE sales_invoice ;
TRUNCATE TABLE sales_invoice_grid ;
TRUNCATE TABLE sales_creditmemo ;
TRUNCATE TABLE sales_creditmemo_grid ;
TRUNCATE TABLE sales_shipment ;
TRUNCATE TABLE sales_shipment_grid ;
SET FOREIGN_KEY_CHECKS=1;
-1
répondu
Kapil Singhathia
2016-07-30 13:29:05