Search code examples
magentomodelsugarcrm

Magento custom model override


I'm new to Magento, so forgive my lack of knowledge. I am following a tutorial to integrate the contacts in Magento and import it to SugarCRM. The tutorial changes the core functions of Magento, but I would like to write a module and leave the core intact. I can easily find information about overriding controllers, models, helper, etc. But I have a question.

Imagining, for example, each time a user registers on my website, his contact information is exported to SugarCRM. In the save contact phase, in my module I know that I can write a specific code and tell that it would need to be run after or before some specific core-functions of Magento are done to save the contacts.
What I really don't understand is, how will Magento know that I have a module that will perform me certain actions when I'm creating a new account?


Solution

  • The way magento handle this is by using events/observers. For instance, if you needed to send order information to another system after an order has been placed, you could create a custom module which observe sales_order_place_after.

    Read more @ http://codemagento.com/2011/04/observers-and-dispatching-events/

    To get a list of events see https://magento.stackexchange.com/questions/153/where-can-i-find-a-complete-list-of-magento-events

    For how to create an module with observer see https://stackoverflow.com/a/12696681/1191288