Search code examples
phpfunctionmagentomagic-methods

Cannot find Function Definition of an Event Observer class in Magento


For anybody who has seen / used Magento, can you please tell me where can I find the following 3 function's definitions of the Catalog Product's save action's Event Observer class:-

  1. setBundleOptionsData()
  2. setBundleSelectionsData()
  3. setCanSaveBundleSelections()

Please pardon me, for asking such a silly question, but I am really helpless. Any help is greatly appreciated.

The worst part is that these above 3 methods are being used for the product object in a nice way, & they are working too. But where are their definitions?

EDIT:-
Okay, I can understand that these are used by the "Varien_Object", and these are simple setter functions using the concept of Magic Methods. But can somebody please tell what is the coding flow, when the program counter arrives at such a function, in this case in the Event Observer class?


Solution

  • If you have run a search on all the files and can't find the definition then these are most likely using PHP's magic methods. Is this class inheriting (directly or indirectly) from Varien_Object? If so, then these are simple setter functions storing data in an array within the object.

    To get these values back all you need to do is change the 'set' to 'get':

    $this->setBundleOptionsData('whatever');
    echo $this->getBundleOptionsData(); //Returns 'whatever'
    

    If you're interested in how this works, look inside class Varien_Object. I've also described the mechanism here.