Magento: eliminare un ordine

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;
}

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>