how to create new custom options type in magento?
Asked Answered
M

3

8

How do I create new product custom options type in magento?

For example, I have to give new image a custom option type in magento which fetches an image from my custom module table, and I want to assign that image to my custom options image field.

Morris answered 8/5, 2012 at 14:1 Comment(4)
For an answer see this article: webmasterbulletin.net/2011/04/… as well as the following question on updating custom options: #10798658Sheaff
yes this create new custom options for products not new custom options type like there is a custom options select and now i want to create new custom options type imageMorris
Sorry – I misunderstood the question first…Sheaff
Been working on this myself, and it is incredibly tricky. It requires some rewrites to core files. It could take many hours, and a lot of deep knowledge of Magento. The four types are fairly hard-coded in. I've been trying to add a fifth type to allow customers to pick a custom "size" in square feet, and it is very difficult. Just wanted to let you know since no one has been replying, it's because it is very tricky.Hungarian
M
2

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.

Morris answered 9/5, 2013 at 6:13 Comment(0)
T
4

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.

Teilo answered 27/9, 2012 at 22:9 Comment(0)
M
2

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.

Morris answered 9/5, 2013 at 6:13 Comment(0)
W
0

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

Welldefined answered 29/6, 2016 at 20:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.