Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

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(
        Mage_Sales_Model_Order::STATE_CLOSED,
        Mage_Sales_Model_Order::STATE_CANCELED
    )
);

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Simply add $collection->getSelect()->reset(Zend_Db_Select::WHERE) to your code.

share|improve this answer
    
Works perfectly, thank you! Sorry I can't upvote but once I get a few more rep I'll be sure to come back :) –  b3njamin Jul 14 at 14:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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