How do you obtain an order repository so you can fetch an order?

You have been asked to display details from the customer’s latest order on the customer’s account dashboard (customer/account/). You create a new custom template to show the information.
How do you obtain an order repository so you can fetch an order?
A. Create a view model and specify an OrderRepositoryInterface argument in the _construct method
B. In your template, add the following:
$orderRepository = ObjectManager::getInstance()->get(OrderRepositoryInterface::class);
C. In your block, add a method with the following: return ObjectManager::getInstance()->get(OrderRepositoryInterface::class);
D. In your template, add the following:
$orderRepository = new OrderRepository();

Download Printable PDF. VALID exam to help you PASS.

4 thoughts on “How do you obtain an order repository so you can fetch an order?

  1. If we look at the following file:
    vendor/magento/module-sales/Model/Order/Creditmemo.php:185
    Then it looks like answer could be C.
    As in the answer A there could be typo in _construct

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.