0

I can use the Magento API (https://magento.redoc.ly/2.4.4-admin/tag/ordersid) to get a list of orders using the following endpoint: "rest/V1/orders/items".

However, this endpoint does not return the increment_id, just the order_id. It also doesn't return the order status.

Is there a way to batch get all the orders within a certain period with their corresponding increment_id? And with their status?

The only way I have thoughts of is:

  1. Get all the orders with the order_id
  2. For each order_id, get the increment_id and status using the following endpoint: "rest/V1/orders/{order_id}"

But this 2nd step is time consuming since it needs to be done for each order, so I would like to avoid it.

1 Answer 1

0

try it like this

protected $orderRepository;

public function __construct(
    ..., 
    \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
){
    ...
    $this->orderRepository = $orderRepository;
}
$orderId = "your order id here";

$order = $this->orderRepository->get($orderId);
$orderIncrementId = $order->getIncrementId();
1
  • but here you are still doing one API request for eacvh order ID... also, I would like to use the REST API. Commented May 9, 2022 at 7:26

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.