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.