3

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?

12

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

  • 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 Jul 14 '14 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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