Thursday, June 30, 2022

[FIXED] How to get all order id with current status as "completed" in prestashop?

Issue

I am trying to get all order ids, i am not sure to use function or execute sql query which one is fast considering the performance ?

Is their any way get it ?


Solution

It's very light query, even if you have tens of thousands of orders.

$orders = Db::getInstance()->executeS('SELECT `id_order` FROM `'._DB_PREFIX_.'orders`');

$ids = array_map(function ($row) {
    return $row['id_order'];
}, $orders);


Answered By - Krystian Podemski
Answer Checked By - David Goodson (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.