Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

SQL - Retrieve all orders that have no invoices
Jr. Member
Total Posts:  12
Joined:  2008-06-01
Reutlingen, Germany


i have a little problem with a magento sql statement. i want to get all orders that have no invoices and the status is pending or on hold.

my first idea was to get all orders with the status and walk through the array of orders and use the hasInvoices() method, but this is too slow resp. not the best way.

$orders Mage::getModel('sales/order')->getCollection()

foreach (
$orders as $order)
if ($order->hasInvoices()) {
echo $order->getIncrementId().': Yes<br>';
else {
echo $order->getIncrementId().': No<br>';

i tried it with joinAttribute(), too. But i don’t know exactly how to use this… is there any tutorial to learn the (Magento/Zend) SQL-Statements?

any ideas?

Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top