Magento – Product load event – regardless of context

collection;product

Is there a single event that I can create an observer for that gets fired when a product is loaded either using getModel or through a collection?

The exact use case i have is that i have a custom product attribute, but in order to return the correct result, further logic needs to be done which is based on other factors? I am then planning to compute this logic after load and store it in another member. If someone has an alternative i would be also grateful for this advice.

Best Answer

You don't need an observer to do this. You can use the attribute backend_model to handle your logic.

If you specify a backend_model with your attribute and you extend the Mage_Eav_Model_Entity_Attribute_Backend_Abstract class within your backend model class you can use the afterLoad, beforeSave, afterSave, beforeDelete or afterDelete methods to execute your own logic.

Using the backend_model is the correct way to implement this sort of logic and is how native Magento attributes do it where they have similiar requirements.