I am trying to modify the Lifetime Sales figure on the admin landing page to include pending_payment orders. I have set up a module as follows:

class Steamdesk_Dashboard_Block_Dashboard_Sales extends Mage_Adminhtml_Block_Dashboard_Sales

And I have the following to set a suitable WHERE clause in the SQL for the collection:

$collection->getSelect()->where('main_table.state NOT IN (?)', array(

However there are already two elements in the WHERE clause array which will cause the above to be ignored, which I can see if I check $collection->getSelect() as follows:

[where] => Array
    [0] => (main_table.status NOT IN('canceled'))
    [1] => AND (main_table.state NOT IN('new', 'pending_payment'))

I know all this code is being run, but my question is how can I clear the existing attributes in the collection's generated SQL query?

1 Answer 1


Simply add $collection->clear()->getSelect()->reset(\Zend_Db_Select::WHERE); to your code above your Query.

  • Works perfectly, thank you! Sorry I can't upvote but once I get a few more rep I'll be sure to come back :)
    – James
    Commented Jul 14, 2014 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.