I have custom options that are added to certain products dynamically using the catalog_controller_product_view event and my own observer.
Related: How to add dynamic Select Custom Options in Observer
I'd like to now use an option renderer other than the default. Ideally, I'd like to set my own type field to the option when created so that it uses my own value, ie:
$optionModel = Mage::getModel('catalog/product_option')
...
->setType('my_option_type')
...
This, of course, requires my custom option type to have an associated Block, Model, etc. This also seems to require rewriting the Mage_Catalog_Model_Product_Option class to include my custom option type.
Unfortunately, the Magento team didn't think these option renderers would have been useful as templates, as the markup is essentially all created in the getValuesHtml() method inside the option's associated block class (ie. Mage_Catalog_Block_Product_View_Options_Type_Select)
How can I set my own renderer (preferably as a template, none of this sloppy getValuesHtml() stuff) to a custom option that is created dynamically on product view?
Really, all I need to do is add some additional data attributes to each option value's input element.
additional_optionsafter I perform necessary price calculations. It's fine that they use default renderers there, since that's pretty much what they are, I simply need to add some data values into the<input>that gets generated. – pspahn Jan 20 '15 at 00:43Foo_Bar_Block_Options_Testin your example) simply "there"? Should it usegetValuesHtml()? Using your example, this doesn't seem to be working. – pspahn Jan 20 '15 at 18:04Mage_Catalog_Block_Product_View_Options_Type_Text– Lord Skeletor Jan 20 '15 at 18:12$option->getOptionHtml()- This is pretty much exactly what I needed, thanks! – pspahn Jan 20 '15 at 18:19