shipping order tracking table name in magento.

If you want to add programmatically order tracking number in magento than you need to use below code.

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

$incrementId = $order1->getIncrementId();
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);

if($order->canShip())
{
$itemQty =  $order->getItemsCollection()->count();
$ship = Mage::getModel('sales/service_order', $order)->prepareShipment($itemQty);
$ship = new Mage_Sales_Model_Order_Shipment_Api();
$shipmentId = $ship->create($incrementId);
}

$shipment_collection = Mage::getResourceModel('sales/order_shipment_collection');
$shipment_collection->addAttributeToFilter('order_id', $orderId );

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', $type)
                 ->setData('number', $code)
                 ->setData('carrier_code', 'custom')
                 ->setData('order_id', $shipment->getData('order_id'))
                 ->save();
        }
}


For add programatically order tracking number you also need this requirement.
Order Id,
Customer Id
Shipping Address Id
Billing Address Id
Store Id.

you can get all the requirement info for order tracking table here

4 comments:

  1. Sometime few educational blogs become very helpful while getting relevant and new information related to your targeted area. As I found this blog and appreciate the information delivered to my database.
    คา ร์ โก้ ส่ง ของ ไป ต่าง ประเทศ

    ReplyDelete
  2. Sometime few educational blogs become very helpful while getting relevant and new information related to your targeted area. As I found this blog and appreciate the information delivered to my database.
    ค่า ส่ง ไปรษณีย์ ไป ต่าง ประเทศ

    ReplyDelete
  3. Wow! This could be one particular of the most useful blogs We have ever arrive across on this subject. Basically Magnificent. I am also a specialist in this topic therefore I can understand your effort
    Best Project Management Software

    ReplyDelete