I am having some trouble with Magento Observers. What I am trying to do is: as I am saving a custom product in my adminhtml form I want to my the product sku with a 3rd party API sku. To do this I created an observer for the save action (savePreDispatch) , able to get the retrieve the SKU from the third party API but now my concern is : how can save to my collection the retrieved SKU in the observer?
I have tried something like $this = $observer -> getEvent() -> getProduct() and then save the SKU but it doesn't appear to work, any ideas?
my config.xml is below
<?xml version="1.0"?> <config> <modules> <Namespace_Module> <version>1.0.3</version> </Namespace_Module> </modules> <global> <resources> <namespace_module_setup> <setup> <module>Namespace_Module</module> <class>Namespace_Module_Model_Resource_Setup</class> </setup> </namespace_module_setup> </resources> <blocks> <namespace_module> <class>Namespace_Module_Block</class> </namespace_module> </blocks> <helpers> <namespace_module> <class>Namespace_Module_Helper</class> </namespace_module> </helpers> <models> <namespace_module> <class>Namespace_Module_Model</class> <resourceModel>namespace_module_resource</resourceModel> </namespace_module> <namespace_module_resource> <class>Namespace_Module_Model_Resource</class> <entities> <product> <table>namespace_module_product</table> </product> </entities> </namespace_module_resource> </models> </global> <adminhtml> <events> <catalog_product_save_before> <observers> <namespace_module> <type>singleton</type> <class>namespace_module/observer</class> <method>catalogProductSaveBefore</method> </namespace_module> </observers> </catalog_product_save_before> </events> </adminhtml> </config>