@@ -277,6 +277,8 @@ public function register()
277
277
}
278
278
279
279
/**
280
+ * Retrieves the collection used to track the shipment's items
281
+ *
280
282
* @return mixed
281
283
*/
282
284
public function getItemsCollection ()
@@ -295,6 +297,8 @@ public function getItemsCollection()
295
297
}
296
298
297
299
/**
300
+ * Retrieves all non-deleted items from the shipment
301
+ *
298
302
* @return array
299
303
*/
300
304
public function getAllItems ()
@@ -309,6 +313,8 @@ public function getAllItems()
309
313
}
310
314
311
315
/**
316
+ * Retrieves an item from the shipment using its ID
317
+ *
312
318
* @param string|int $itemId
313
319
* @return bool|\Magento\Sales\Model\Order\Shipment\Item
314
320
*/
@@ -323,6 +329,8 @@ public function getItemById($itemId)
323
329
}
324
330
325
331
/**
332
+ * Adds an item to the shipment
333
+ *
326
334
* @param \Magento\Sales\Model\Order\Shipment\Item $item
327
335
* @return $this
328
336
*/
@@ -353,6 +361,8 @@ public function getTracksCollection()
353
361
}
354
362
355
363
/**
364
+ * Retrieves all available tracks in the collection that aren't deleted
365
+ *
356
366
* @return array
357
367
*/
358
368
public function getAllTracks ()
@@ -367,6 +377,8 @@ public function getAllTracks()
367
377
}
368
378
369
379
/**
380
+ * Retrieves a track using its ID
381
+ *
370
382
* @param string|int $trackId
371
383
* @return bool|\Magento\Sales\Model\Order\Shipment\Track
372
384
*/
@@ -381,6 +393,8 @@ public function getTrackById($trackId)
381
393
}
382
394
383
395
/**
396
+ * Addes a track to the collection and associates the shipment to the track
397
+ *
384
398
* @param \Magento\Sales\Model\Order\Shipment\Track $track
385
399
* @return $this
386
400
*/
@@ -409,8 +423,7 @@ public function addTrack(\Magento\Sales\Model\Order\Shipment\Track $track)
409
423
}
410
424
411
425
/**
412
- * Adds comment to shipment with additional possibility to send it to customer via email
413
- * and show it in customer account
426
+ * Adds comment to shipment with option to send it to customer via email and show it in customer account
414
427
*
415
428
* @param \Magento\Sales\Model\Order\Shipment\Comment|string $comment
416
429
* @param bool $notify
@@ -574,13 +587,10 @@ public function setItems($items)
574
587
public function getTracks ()
575
588
{
576
589
if ($ this ->getData (ShipmentInterface::TRACKS ) === null ) {
577
- $ collection = $ this ->_trackCollectionFactory ->create ()->setShipmentFilter ($ this ->getId ());
578
- if ($ this ->getId ()) {
579
- foreach ($ collection as $ item ) {
580
- $ item ->setShipment ($ this );
581
- }
582
- $ this ->setData (ShipmentInterface::TRACKS , $ collection ->getItems ());
590
+ foreach ($ this ->getTracksCollection () as $ item ) {
591
+ $ item ->setShipment ($ this );
583
592
}
593
+ $ this ->setData (ShipmentInterface::TRACKS , $ this ->getTracksCollection ()->getItems ());
584
594
}
585
595
return $ this ->getData (ShipmentInterface::TRACKS );
586
596
}
0 commit comments