I want to get order detail with customized some information using order API. I want to override API:


How can I override in Magento 2.3

1 Answer 1


You'll need to add an after plugin to the order repository in the webapi_rest area. Follow the next steps

  1. Create the file Vendor/Module/etc/webapi_rest/di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="\Magento\Sales\Model\OrderRepository">
        <plugin name="order_repository" type="Vendor\Module\Plugin\Magento\Sales\Model\OrderRepository" disabled="false" sortOrder="200" />
  1. Add the plugin Vendor/Module/Plugin/Magento/Sales/Model/OrderRepository.php

namespace Vendor\Module\Plugin\Magento\Sales\Model;

use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Model\OrderRepository as ModelOrderRepository;

class OrderRepository

     * @param ModelOrderRepository $orderRepository
     * @param OrderInterface $order
     * @return OrderInterface
    public function afterGet(
        ModelOrderRepository $orderRepository,
        OrderInterface $order
    ) {

        // Change the value for the order here
        return $order;
  • will it work only for order API? Aug 6, 2020 at 8:34
  • Yes, only for order API
    – Rus0
    Aug 6, 2020 at 18:17
  • thanks, it is working & now I am able to change order data. Aug 7, 2020 at 6:26
  • How we can item base price using it ? Jul 11, 2023 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.