我在這裏刪除使用下面的代碼的順序,但它仍然顯示在訂單網格中。當我點擊這個訂單時,它顯示「此訂單不再存在」。但在運行下面的代碼後,我不需要顯示順序。刪除magento訂單
<?php
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('default');
Mage::register('isSecureArea', 1);
//until here you gained access to the Magento models. The rest is custom code
$orders_object = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('increment_id', 100000025);
$orders_arr = $orders_object->getData();
if(!empty($orders_arr)){
$orders_data = $orders_arr[0];
$orderId = $orders_data['entity_id'];//put here the id of the order you want to delete. THE ONE FROM THE DATABASE NOT THE INCREMENT_ID
$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();
echo "deleted";
}else{
echo "no record";
}
?>
在何處放置此代碼。我只是把它放在我的代碼的上面。它仍然顯示在網格 – 2013-03-11 14:15:51
@muralikalpana嗨使用此行$ order_in_grid-> getFirstItem() - > delete();它會通過magento模型正確地刪除訂單中的訂單 – Haijerome 2013-03-11 14:48:10