简体   繁体   English

如何从Magento中删除意外创建的货件?

[英]How to delete a shipment from Magento that was created accidentally?

How can I remove a shipment that was created accidentally? 如何删除意外创建的货件? I know there is no way to do it through the admin, but I'm trying to figure out what I need to do to revert an order back to a status of "Processing" along with all the old shipment information so it can be shipped at a later time. 我知道没有办法通过管理员这样做,但我想弄清楚我需要做什么才能将订单恢复到“处理”状态以及所有旧的货件信息,以便它可以发货晚些时候。 I'm hoping this can be done programmatically via PHP or even just directly in MySQL. 我希望这可以通过PHP以编程方式完成,甚至可以直接在MySQL中完成。

FYI, I'm using Magento version 1.1.8. 仅供参考,我正在使用Magento 1.1.8版。

Try 尝试

require_once  'app/Mage.php';

Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('default');
Mage::register('isSecureArea', 1);


//Update Order id
$orderId = xyz;


$order = Mage::getModel('sales/order')->load($orderId);

// check if has shipments
if(!$order->hasShipments()){
    die('No Shipments');
}

//delete shipment
$shipments = $order->getShipmentsCollection();
foreach ($shipments as $shipment){
    $shipment->delete();
}

// Reset item shipment qty
// see Mage_Sales_Model_Order_Item::getSimpleQtyToShip()
$items = $order->getAllVisibleItems();
foreach($items as $i){
   $i->setQtyShipped(0);
   $i->save();
}

//Reset order state
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Undo Shipment');
$order->save();

echo 'Done';
$shipment = Mage::getModel('sales/order_shipment')->load($shippingOrderId);
$shipment->delete();

I assume this works. 我认为这是有效的。 I haven't tried it. 我没试过。

I ended up purchasing the extension below which did the trick beautifully. 我最终购买了下面的扩展程序。 Even though it doesn't say it supports versions prior to 1.3, it worked flawlessly on my setup of v1.1.8. 虽然它没有说它支持1.3之前的版本,但它在我的v1.1.8设置上运行完美。

http://www.magentocommerce.com/magento-connect/delete-shipment-6498.html http://www.magentocommerce.com/magento-connect/delete-shipment-6498.html

Say you shipped an order in its entirety and didn't mean to. 假设您完整地发送了订单,并不是故意的。 Just delete the INVOICE. 只需删除INVOICE即可。 It will remove the invoice and any of the shipments...SHIPMENTS plural! 它将删除发票和任何货物......装运复数!

So you have to be careful, if you have other shipments you will need to recreate them. 所以你必须要小心,如果你有其他货物,你需要重新创建它们。 Then invoice it again. 然后再发票。 Then it will be just like you never shipped anything and you can then SHIP whatever quantity you originally required. 然后它就像你从未发过任何东西一样,然后你可以SHIP你最初需要的数量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM