Home » Php » php – how to create new custom options type in magento?

php – how to create new custom options type in magento?

Posted by: admin July 12, 2020 Leave a comment


How to create new product custom options type in magento, for example I have to give new image custom option type in magento which fetch image from my custom module table and I want to assign that image to my custom options image field .

How to&Answers:

As Dustin Graham said, it is very tricky. First steps:

  1. Add new node under global/catalog/product/options/custom/groups. See examples in /app/code/core/Mage/Catalog/etc/config.xml.

  2. Create new block to render your custom option.

  3. 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.

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');

                <?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;?>


You can then hide the select and interact with the select through jQuery.