WonderLand WonderLand - 2 years ago 121
SQL Question

Magento: not shipped item collection

I would like to get all items that has not been shipped for a given order.

Suppose that I have a partial shipped order I would like to retrieve all items that are pending to be shipped.

Something like:

$collection = Mage::getModel('...')->getCollection()

Answer Source
$orderId = 382;

$order = Mage::getModel('sales/order')->load($orderId);
// OR if you load the order with increment id ...
// $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); 
$orderItems = $order->getItemsCollection();

foreach ($orderItems as $item) {

    $qtyToBeShipped = $item->getQtyOrdered() - $item->getQtyShipped();

    if ($qtyToBeShipped)
        echo $item->getId() . ' - ' . $qtyToBeShipped . '</br>';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download