I want to get order detail with customized some information using order API. I want to override API:
https://example.com/index.phprest/V1/orders
How can I override in Magento 2.3
I want to get order detail with customized some information using order API. I want to override API:
https://example.com/index.phprest/V1/orders
How can I override in Magento 2.3
You'll need to add an after plugin to the order repository in the webapi_rest area. Follow the next steps
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" /> </type> </config> Vendor/Module/Plugin/Magento/Sales/Model/OrderRepository.php<?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; } }