Question

I've looked at

How to get ordered items associated with tracking numbers?

How to Access Shipment from Order ID and product ID?

How to get the shipment number of an order item?

Create part shipment and check if item has been shipped

None have worked for what I'm trying to do.

I have the shipment ID in a variable $shipid. Is there anyway to get the products that go with the shipment ID?

I have my figures crossed!

Thanks

Was it helpful?

Solution

First you need to load the shipment:

$shipment = Mage::getModel('sales/order_shipment')->load($shipid);

If you're using the increment id, you'll have to use:

$shipment = Mage::getModel('sales/order_shipment')->loadByIncrementId($shipid);

Once you have the shipment loaded, you can retrieve the items collection:

$itemsCollection = $shipment->getItemsCollection(); 

Finally to get the product from the items you can loop through the item collections:

foreach($itemsCollection as $item)
{
    $_product = $item->getProduct();
}

OTHER TIPS

change $item->getProduct(); To $item->getData();

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top