My objective is to send an order to our backend system when a order is placed within our Magento 2 instance.
The code to send the order object is working. My question is what is the optimum approach to retrieve item
data (e.g. price
, subtotal
, total
, sku
, etc.).
I'm using the following to retreive the order and items.
$orderId = $this->_order->load($order);
$billing = $orderId->getBillingAddress();
$items = $orderId->getAllItems();
foreach ($items as $item) {
$itemPrice = $item->getPrice();
$itemSku = $item->getSku();
}
Is iterating through $items
to get price, sku, etc. the best way or is there a Magento2 collection/method
I should be using?
Thanks
print_r(orderId->getAllItems())
output all the items?