In the orders api of Magento 2, I'm sending status parameter as completed.

But I have custom status as "ProdCompleted.

So everytime I get status="completed" That's why I want that if api get parameter status="completed" then it should send the response for status="ProdCompleted"


How can I do this? can I override the Orders API? If yes, then How can I override the orders API?


You can create an after plugin for magento\module-sales\Model\Order.php for getStatus() and check if status="completed" replace with status="ProdCompleted.

I made a sample module for you


I have not tested the code , let me know if you face any issue

| improve this answer | |
  • yes checking... – Prashant Patil Jan 28 '19 at 6:13
  • public function afterGetStatus( \Magento\Sales\Model\Order $subject, $result ) { //Your plugin code } I got this code into Order.php, so can I add return $subject=ProdCompleted; OR return $result=ProdCompleted; – Prashant Patil Jan 28 '19 at 6:15
  • You need execute and test – Vishwas Bhatnagar Jan 28 '19 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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