In my resource model I have defined a field as serializable (see property $_serializableFields
in Mage_Core_Model_Resource_Db_Abstract
): Magento handles automatically serialization/unserialization of the contents when loading data from the database and before saving the object.
This works perfectly, but when I iterate over a collection of those objects, the field contents are not unserialized automatically. I tried with $collection->walk('afterLoad')
but soon realized that unserializeFields()
is triggered in the resource model load()
, and not in afterLoad()
like I first thought. What is the best practice in this case? How do I get this field unserialized automatically? I can of course reload the object in my loop, doing something like $object = $object->load($object->getId())
, but I was wondering if there is a smarter way to achieve this.