Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alisamie97/50b2deb119ee839633c242ad84e03ddc to your computer and use it in GitHub Desktop.
Save alisamie97/50b2deb119ee839633c242ad84e03ddc to your computer and use it in GitHub Desktop.
How to get all orders with certain current state in Prestashop? (Symfony Entity Manager)
<?php
use PrestaShop\PrestaShop\Adapter\ServiceLocator;
class [Nameofyourmodule][Nameofmodulefrontcontrollerfile]ModuleFrontController 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;
}
}
@samberrry
Copy link

SymfonyContainer::getInstance()->get()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment