One of my previous articles was a Magento Event Hooks. This one will be a practical example on using the event hooks. Although the more proper way would be to call them Observers, bare with me. I’m use to this “hooks”.
Here’s the walk-trough on how to add a new property (attribute) to an object (Mage_Sales_Model_Order object in our case).
To add an attribute to object, we need (the dirty way) 2 little steps
- Go to app/code/core/Mage folder. If you drill down into most of the folders and go to /Model subfolder there you will see /Entity subfolder under /Model for most of the stuff (modules) under /Mage. For our example we go to app/code/core/Mage/Sales/Model/Entity/Setup.php file. This Setup.php file holds Objects fields definitions in database. We need to add new fields to public function getDefaultEntities(). Once again, this is the “quick” and “dirty” way of adding new attributes.