As the new Prestashop is using Symfony, this is how to query the database:
$this->entityManager = ServiceLocator::get('\\PrestaShop\\PrestaShop\\Core\\Foundation\\Database\\EntityManager'); $id_order_state = 5; $orders = $this->entityManager->getRepository('Order') ->findBy([ 'current_state' => $id_order_state ]);
You can use this in a front controller like this:
<?php use PrestaShop\PrestaShop\Adapter\ServiceLocator; class MymoduleTestcontrollerModuleFrontController extends ModuleFrontController { private $entityManager; public function __construct() { parent::__construct(); $this->entityManager = ServiceLocator::get('\\PrestaShop\\PrestaShop\\Core\\Foundation\\Database\\EntityManager'); } public function initContent() { parent::initContent(); $id_order_state = 5; $orders = $this->entityManager->getRepository('Order') ->findBy([ 'current_state' => $id_order_state ]); echo '<pre>'; print_r($orders); echo '</pre>'; die; } }