How I can get collection of items associated to that particular tracking numbers for each shipment of order using order id?
Shipment Tracking – How to Get Ordered Items Associated with Tracking Numbers
ce-1.7.0.2shipmentshipment-tracking
ce-1.7.0.2shipmentshipment-tracking
How I can get collection of items associated to that particular tracking numbers for each shipment of order using order id?
Best Answer
You need to keep in mind that each order can have multiple shipments and that each shipment can have multiple tracking numbers with multiple products.
Solution 1
After looking at
app/code/core/Mage/Sales/Model/Order/Shipment.php
you see that there are two methods of interest:getAllItems()
andgetAllTracks()
Which you can then use on your
$order
objectSolution 2 - Direct SQL Statements
The reason I'm including this is because I always find it very useful to check the database structure when I'm struggling with something. After a quick glance at the database, you see some notable tables namely:
sales_flat_shipment
,sales_flat_shipment_item
andsales_flat_shipment_track
Immediately with these tables in mind, you know pretty much exactly how to find what you are looking for by simply looking at their column names.