Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ShippingLabelConverter.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
14 {
24  public function afterGetList(
25  \Magento\Sales\Api\ShipmentRepositoryInterface $shipmentRepository,
26  \Magento\Sales\Api\Data\ShipmentSearchResultInterface $searchResult
27  ) {
29  foreach ($searchResult->getItems() as $item) {
30  if ($item->getShippingLabel() !== null) {
31  $item->setShippingLabel(base64_encode($item->getShippingLabel()));
32  }
33  }
34  return $searchResult;
35  }
36 
46  public function afterGet(
47  \Magento\Sales\Api\ShipmentRepositoryInterface $shipmentRepository,
48  \Magento\Sales\Api\Data\ShipmentInterface $shipment
49  ) {
50  if ($shipment->getShippingLabel() !== null) {
51  $shipment->setShippingLabel(base64_encode($shipment->getShippingLabel()));
52  }
53  return $shipment;
54  }
55 }
afterGet(\Magento\Sales\Api\ShipmentRepositoryInterface $shipmentRepository, \Magento\Sales\Api\Data\ShipmentInterface $shipment)
foreach($order->getItems() as $orderItem) $shipment