Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

_afterLoad() not being called after a collection is loaded. 
 
miked2004
Sr. Member
 
Avatar
Total Posts:  214
Joined:  2007-12-13
Atlanta, Georgia
 

I think I am going about this right, but maybe not. I created a custom module and wanted to do some logic in the _afterLoad method.

I have these classes:
class Essex_Brakecompound_Model_Brakecompound extends Mage_Core_Model_Abstract

class Essex_Brakecompound_Model_Mysql4_Brakecompound extends Mage_Core_Model_Mysql4_Abstract

class Essex_Brakecompound_Model_Mysql4_Brakecompound_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract

I thought that if I added an _afterLoad() in class Essex_Brakecompound_Model_Mysql4_Brakecompound that it would run after a collection is created. This doesn’t seem to happen though.

if I call Mage::getModel(brakecompound/brakecompound)->load(8); the after load runs but it dosn’t after I do Mage::getModel(brakecompound/brakecompound)->getCollection(); I then loop through the collection and the _afterLoad still doesnt run. Am I missing something?

I am trying to add data to each brakecompound object after it is loaded.

Any help is greatly appreciated…

 
Magento Community Magento Community
Magento Community
Magento Community
 
retif
Sr. Member
 
Total Posts:  171
Joined:  2008-08-16
Odessa, Ukraine
 

see Mage_Eav_Model_Entity_Collection_Abstract. but it uses eav thing

Mage_Core_Model_Mysql4_Collection_Abstract is simplified alternative to use with flat tables.

u can make your own load() method which will call _afterLoad()

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top