Piotr Kaczor Posted January 3, 2014 Share Posted January 3, 2014 Hello I'm looking for method to get all orders (maybe all id_order) with specific, currently set, status. Thank You for advice, Best Regards. Link to comment Share on other sites More sharing options...
vekia Posted January 3, 2014 Share Posted January 3, 2014 sql query: SELECT * FROM ps_orders o INNER JOIN ps_order_history oh ON o.id_order = oh.id_order WHERE id_order_state = 10 or Order object: $orders= Order::getOrderIdsByStatus(10); 1 Link to comment Share on other sites More sharing options...
Piotr Kaczor Posted January 3, 2014 Author Share Posted January 3, 2014 Thank You vekia really helpful Link to comment Share on other sites More sharing options...
vekia Posted January 4, 2014 Share Posted January 4, 2014 you're welcome thread marked as [solved] Link to comment Share on other sites More sharing options...
joseantgv Posted November 24, 2015 Share Posted November 24, 2015 Why function getOrderIdsByStatus() has been deprecated since PS 1.5.0.3 and there is not any alternative? 1 Link to comment Share on other sites More sharing options...
Ali Samie Posted July 23, 2022 Share Posted July 23, 2022 (edited) 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; } } Edited July 23, 2022 by stifler97 (see edit history) 2 Link to comment Share on other sites More sharing options...
ventura Posted July 23, 2022 Share Posted July 23, 2022 You can also use a filter with Order::getOrdersWithInformations(), eg $records = array_filter(Order::getOrdersWithInformations(), function ($record) use ($level) { return $record['current_state'] == 10; }); 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now