how to create new custom options type in magento?
As Dustin Graham said, it is very tricky. First steps:
Add new node under
global/catalog/product/options/custom/groups
. See examples in/app/code/core/Mage/Catalog/etc/config.xml
.Create new block to render your custom option.
Rewrite
Mage_Catalog_Model_Product_Option
and implement saving your custom type options (saveOptions()
method) and loading your custom type options (getProductOptionCollection
method).
If your custom type isn't very custom :) - it should be enough.
I forgot this question but i need again to create new custom option type in my another project. I had Created new custom options type using this link. http://magento.ikantam.com/qa/custom-input-types-custom-options
Solution is bit lengthy and its not possible to put whole code here, so i have just share this link, going through this link i had create new custom options type easily, explanation is good in this article.
I have modify some changes for my need .
Hope this will help some one.
As Dustin Graham said its incredibly tricky.
@Mufaddal thanks for sharing this link. I'd like to offer an alternative to this since it requires quite a bit knowledge.
If you're only trying to change the way a specific dropdown (for example) is displayed you can also overwrite the /template/catalog/product/view/options/type/select.phtml
as follows:
` getOption() ?>
<dt><label<?php if ($_option->getIsRequire()) echo ' class="required"' ?>><?php if ($_option->getIsRequire()) echo '<em>*</em>' ?><?php echo $this->escapeHtml($_option->getTitle()) ?></label> </dt><dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>><div class="input-box"> <?php echo $this->getValuesHtml(); ?> <?php if($_option->option_id == 2) : ?> <script type="text/javascript"> jQuery('#select_2').css('display', 'none'); </script> <?php foreach ($_option->getValues() as $_value) { ?> <?php echo $_value->getTitle(); // the title of the option ?> <?php echo $_value->getOptionTypeId(); // the id ?> <?php } ?> <!-- add custom code that triggers select in the background --> <?php endif ?> <?php if ($_option->getIsRequire()): ?> <?php if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX): ?> <span id="options-<?php echo $_option->getId() ?>-container"></span> <?php endif; ?> <?php endif;?></div>
`
You can then hide the select and interact with the select through jQuery.