Created
December 7, 2011 14:46
-
-
Save razbakov/1443068 to your computer and use it in GitHub Desktop.
Shipment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @var $order Mage_Sales_Model_Order */ | |
$order = Mage::getModel('sales/order'); | |
$order->load($orderId); | |
/** @var $shipment Mage_Sales_Model_Order_Shipment */ | |
$shipment = Mage::getModel('sales/order_shipment'); | |
$shipment->setOrder($order); | |
foreach($trackingNumbers as $trackingNumber) { | |
/** @var $shipmentTrack Mage_Sales_Model_Order_Shipment_Track */ | |
$shipmentTrack = Mage::getModel('sales/order_shipment_track'); | |
$shipmentTrack->setCarrierCode('Hega'); | |
$shipmentTrack->setNumber($trackingNumber); | |
$shipmentTrack->save(); | |
$shipment->addTrack($shipmentTrack); | |
} | |
$shipment->save(); | |
$order->setState($afterImportStatus, true, $orderMessage, $isCutomerNotified); | |
$order->save(); | |
// I have this error: | |
/* | |
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento`.`sales_flat_shipment_track`, CONSTRAINT `FK_BCD2FA28717D29F37E10A153E6F2F841` FOREIGN KEY (`parent_id`) REFERENCES `sales_flat_shipment` (`entity_id`) ON DELETE CASCADE ON UPDATE CAS) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment