Magento : programmatically add custom options for products

I've found plenty of places on magento forums and websites that mention adding custom options to products : none of them seemed to work on my installation (1.5) so I suppose each version has its own tweaks. The technique below catches a specific event that is fired when the product is being saved from the admin. A good tutorial on Magento events can be found here, pseudo official list of events can also be found on Magento's wiki, probably outdated though. What I need now is to find the appropriate code to delete options from a product. not simple either... Anyone tried?

The way I did is the following

  • create a custom module PoleOuest_CustomOptions_Model_Observer 
    app/local/PoleOuest/CustomOptions/Model/Observer.php




  • catch product save before event in app/local/PoleOuest/CustomOptions/etc/config.xml