Quote:
Originally Posted by Soptareanu Alex
Hello I need to retrive some order by shipping status. For that task I try to use query builder but I get some errors.
This is my query :
$aBackOrders = \XLite\Core\Database::getRepo('\XLite\Model\Order' )
->createQueryBuilder('o')
->andWhere('o.shipping_status_id = :id')
->setParameter('id', 4)
->getResult();
And this is the error that i get :
[Semantical Error] line 0, col 78 near 'shipping_status_id': Error: Class XLite\Model\Order has no field or association named shipping_status_id
What I'm doing wrong ?
|
Your request should be as follows:
Code:
$aBackOrders = \XLite\Core\Database::getRepo('\XLite\Model\Order')
->createQueryBuilder('o')
->andWhere('o.shippingStatus = :id')
->setParameter('id', 4)
->getResult();
Doctrine only works with properties in model class (in your case \XLite\Model\Order) and there is no property called 'shipping_status_id'. Instead you should work with 'shippingStatus' property and you can specify its value as ID (in my example) or as an entire \XLite\Model\Order\Status\Shipping object.
Please, let me know if it helps.
Tony