You can get item collection data by Item id in Magento 2 by using below code snippet, Create Block file,
<?php
namespace Rbj\Training\Block;
class Item extends \Magento\Framework\View\Element\Template
{
public function __construct(
\Magento\Framework\View\Element\Template $context,
\Magento\Sales\Api\OrderItemRepositoryInterface $orderItemRepository,
array $data = []
) {
$this->orderItemRepository = $orderItemRepository;
parent::__construct($context, $data);
}
/* get order Item collection */
public function getOrderItem($itemIid)
{
$itemCollection = $this->orderItemRepository->get($itemId);
return $itemCollection;
}
}
Call function from the Template file,
$itemId = 10; // order item id
$getItemCollection = $block->getOrderItem($itemId);
echo $getItemCollection->getOrderId();
echo "<pre>";print_r($getItemCollection->debug());