<?php
$orderid = 1;
$order = Mage::getModel('sales/order')->load($orderid );
$shipmentItems = array();
foreach ($order->getAllItems() as $item) {
$shipmentItems [$item->getId()] = $item->getQtyToShip();
}
// Prepear shipment and save ....
if ($order->getId() && !empty($shipmentItems) && $order->canShip()) {
$shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($shipmentItems);
$shipment->save();
}
$shipment_collection = Mage::getResourceModel('sales/order_shipment_collection');
$shipment_collection->addAttributeToFilter('order_id', $data[0]);
foreach($shipment_collection as $sc) {
$shipment = Mage::getModel('sales/order_shipment');
$shipment->load($sc->getId());
if($shipment->getId() != '') {
$track = Mage::getModel('sales/order_shipment_track')
->setShipment($shipment)
->setData('title', $data[5])
->setData('number', $data[6])
->setData('order_id', $shipment->getData('order_id'))
->save();
}
}
?>
$orderid = 1;
$order = Mage::getModel('sales/order')->load($orderid );
$shipmentItems = array();
foreach ($order->getAllItems() as $item) {
$shipmentItems [$item->getId()] = $item->getQtyToShip();
}
// Prepear shipment and save ....
if ($order->getId() && !empty($shipmentItems) && $order->canShip()) {
$shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($shipmentItems);
$shipment->save();
}
$shipment_collection = Mage::getResourceModel('sales/order_shipment_collection');
$shipment_collection->addAttributeToFilter('order_id', $data[0]);
foreach($shipment_collection as $sc) {
$shipment = Mage::getModel('sales/order_shipment');
$shipment->load($sc->getId());
if($shipment->getId() != '') {
$track = Mage::getModel('sales/order_shipment_track')
->setShipment($shipment)
->setData('title', $data[5])
->setData('number', $data[6])
->setData('order_id', $shipment->getData('order_id'))
->save();
}
}
?>
No comments:
Post a Comment