Im starting to understand how Magento Event Observers work and hoping someone could help me figure out what Event I would need to seek out to get my potential module to work. I have certain products that have an attribute called “child skus” which is an array of SKU numbers of other products in my inventory.
Example:
Name: Totally Awesome Product
SKU: TP-1212
Child SKUS: GP-3232,FD-4332,VC-5332
Every time someone purchases TP-1212 I also need Magento to deduct that quantity from those child skus behind the scenes. Does anyone know if there is an event dispatcher for after a purchase has been completed that would handle something like that??
This is a little tricky and there are most likely some edge cases not covered in the below code – Also the answer assumes the following:
Code:
So, you obviously need to create a module first. The config.xml needs to declare the observer which will listen to
checkout_type_onepage_save_order_after. (Note: there are other events you can listen to in order to achieve your goal).The config.xml will contain the following code at a minimum:
Then in your observer: