One of my client's CRON daemon recently started sending those errors:

PHP Fatal error: Call to a member function addFieldToFilter() on a non-object in /app/code/core/Mage/Cron/Model/Observer.php on line 105

Running Magento

This corresponds to the following lines:

$this->_pendingSchedules = Mage::getModel('cron/schedule')->getCollection()
            ->addFieldToFilter('status', Mage_Cron_Model_Schedule::STATUS_PENDING)

I've already ensured that the Mage_Cron_Model_Resource_Schedule_Collection class exists and the file is at the right location.

I've also checked the cron_schedule table and cron is running fine, most of the scheduled job are in the success status and there's a few pending jobs as well.

I'm not quite sure where I should start debugging. Any clue where I should start looking to narrow down the issue ?

  • 1
    You should start by asking your client what on Earth he has done... But yes technically, check if a module hasn't been installed, or if a file hasn't been deleted by mistake Commented Jun 14, 2016 at 15:52
  • @Mayers yep that's what I will do but I was thinking maybe it's a known Magento issue and it has nothing to do with the client ^^ Commented Jun 14, 2016 at 15:54
  • Not to my knowledge. The reason addFieldToFilter freaks out, is probably because your getCollection returns NULL. Make sure there is also a Cron/Model/Resource/Schedule folder. Otherwise, it's hard to tell what could exactly cause this without more context. But check when the cron last ran properly, something changed at that time Commented Jun 14, 2016 at 15:56
  • @Mayers yes I checked that and it's all good Commented Jun 14, 2016 at 15:57

1 Answer 1


The code in question is:

        $this->_pendingSchedules = Mage::getModel('cron/schedule')->getCollection()
            ->addFieldToFilter('status', Mage_Cron_Model_Schedule::STATUS_PENDING)

Based on that, your problem is that getCollection() is not returning the object Magento expects. Is anything overriding cron/schedule, or its collection cron/resource_schedule_collection?

I would suggest adding logging in there to determine the exact type (get_class($var)) of Mage::getModel('cron/schedule') and Mage::getModel('cron/schedule')->getCollection() in that context. That should give you an idea of where to proceed. Let it run, see what comes out.

It's hard to speculate about the root cause without more info. I suspect a problem with configuration (module XML), either a file being broken, or some module overriding or replacing some XML it shouldn't.


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.