Created
July 23, 2022 06:58
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SymfonyContainer::getInstance()->get()