Search code examples
phpprestashop

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


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);