If you have a model, normally there should be a resource model and a resource collection too, but there are some core models where this is not the case.

Example: Mage_Log_Model_Customer

I tried to answer another question and thought its possible to get data from this models collection directly ...

$model = Mage::getModel('log/customer')->getCollection();
foreach ($model as $item) {

But it doesn't work ...

$model = Mage::getModel('log/customer');

.... gives valid output like ...

array (size=54)
  7 => string 'getCollection' (length=13)

Okay so far, but doing ...

$model = Mage::getModel('log/customer')->getCollection();

... just returns null. Reason for this is, there is no Mage_Log_Model_Resource_Customer_Collection.

Adding this file there ...

class Mage_Log_Model_Resource_Customer_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
    protected function _construct()

... gives access to this DB table.

Is there any reason for not adding "Resource Collection" classes for some models? Anything that could break Magento? Just forgot to add these files?


A missing resource collection model is not the same as a missing resource model.
I don't have an answer to why this is missing, I can just assume that in the core there was no need for a collection resource model for the Mage_Log_Model_Customer.
The log module is used just to log the customer activity and to be able to see when the customer last logged in.
There is no case when you need the full collection of logs.

| improve this answer | |
  • Still think there should be a resource (collection) models too ... used or not. – sv3n Feb 5 '18 at 23:57

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.