4

I've defined some logic in the _afterLoad() for one of my models. When loading one model using Mage::getModel('foo/bar)->load(1) _afterLoad() is triggered and the extra data values are set. When loading a collection, though, _afterLoad is not triggered on every model. How can I make it work that a collection returns its models with _afterLoad() automatically executed?

4

The _afterLoad method in the models is not meant to be loaded when the collection is loaded.
But there is an _afterLoad method available for db collections also.
You can use that to implement your logic for a collection load.

  • That's lame ;p So in the collection _afterLoad() method you would loop over the loaded models and then you would call the public function afterLoad() on all of these models, right? – Maarten Troonbeeckx Aug 26 '16 at 10:21

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.