I am trying to get items of an order and display it in phtml file. But not getting the result.
Below provided is the code which I have provided in block
protected $_order;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Customer\Model\Session $session,
\Cubet\RMA\Model\ListReturnsFactory $db,
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory,
\Magento\Sales\Model\Order $order
) {
parent::__construct($context);
$this->_session = $session;
$this->_logger = $context->getLogger();
$this->_db = $db;
$this->_orderCollectionFactory = $orderCollectionFactory;
$this->_order = $order;
}
public function getOrderItems()
{
$orderItems = $this->_order->create()->loadByIncrementId(000000003);
$orderItems->getAllItems();
return $orderItems;
}
and the code provided in phtml is
$items = $block->getOrderItems();
print_r($items);
but it doesn't print any result. Please help on the same.
$orderItems = $this->_order->create()->loadByIncrementId('000000003');