Home > Magento > Magento: eliminare un ordine

Magento: eliminare un ordine

November 15th, 2011 Nicola Leave a comment Go to comments

La versione di Magento è la 1.5.0.1.

Questa funzione elimina un ordine con relative fatture, note di credito e spedizioni. Da usare sotto la supervisione di un adulto.

function deleteOrder($orderId) {
 
    $order = Mage::getModel('sales/order')->load($orderId);
 
    $invoices = $order->getInvoiceCollection();
    foreach ($invoices as $invoice){
        $invoice->delete();
    }
    $creditnotes = $order->getCreditmemosCollection();
    foreach ($creditnotes as $creditnote){
        $creditnote->delete();
    }
    $shipments = $order->getShipmentsCollection();
    foreach ($shipments as $shipment){
        $shipment->delete();
    }
    $order->delete();                
 
    return 0;
}
Categories: Magento Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.