1

I have used the the link for create a extension to add Custom Options in the admin. Now it works in admin part, But when i create the custom view part for product, it did not work for me. First thing i cant understand where i add the bellow code in my config.xml file.

<catalog_product_view>
    <reference name="product.info.options">
        <action method="addOptionRenderer">
            <type>instagramimage</type>
            <block>webtoprint/catalog_product_view_options_type_instagramimage</block>
            <template>webtoprint/catalog/product/view/options/type/instagramimage.phtml</template>
        </action>
    </reference>
</catalog_product_view>

What is the Customized method in it

class Ikantam_Webtoprint_Block_Options_Type_Customview_Instagramimage
    extends Mage_Core_Block_Template
{
    protected $_template = 'webtoprint/options/customview/instagramimage.phtml';
}

Where it works ? I cant understand how the instagramimage.phtml display on the frontend.

<?php /** @var $this Ikantam_Webtoprint_Block_Options_Type_Customview_Instagramimage */ ?>
<?php $data = $this->getInfo(); ?>
<h1><?php echo $data['value'] ; ?></h1>

Al last what what is the template here and how i can use it ?

<?php /** @var $this Ikantam_Webtoprint_Block_Catalog_Product_View_Options_Type_Instagramimage */ ?>
<?php $_option = $this->getOption(); ?>
<dt><label<?php if ($_option->getIsRequire()) echo ' class="required"' ?>><?php if ($_option->getIsRequire()) echo '<em>*</em>' ?><?php echo  $this->htmlEscape($_option->getTitle()) ?></label>
    <?php echo $this->getFormatedPrice() ?></dt>
<dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>>
    <div class="input-box">
        <input type="text"
               id="options_<?php echo $_option->getId() ?>_instagramimage"
               class="<?php echo $_option->getIsRequire() ? ' required-entry' : '' ?>"
               name="options[<?php echo $_option->getId() ?>]"
               value="<?php echo $this->escapeHtml($this->getDefaultValue()) ?>" />
    </div>
</dd>

Now i can get the custom option in my admin section, But When i add some value like

Title * Input Type *          Is Required   Sort Order
Test        text(Instagramimage)   yes                  0

Price   Price Type  SKU
450.00      fixed           34

I found the input box with title given, but could not find the price value. As frontend it could not save the price value in backend also.In data base SKU value has saved but not the price value.

0

I have got this issue too.

After digging the code, i found the key point is this function: _saveValuePrices() in class Mage_Catalog_Model_Resource_Product_Option.

        if ($object->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_FIELD
        || $object->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_AREA
        || $object->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_FILE
        || $object->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE
        || $object->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE_TIME
        || $object->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_TIME
    ) {}

You need add your type in here.

Hope this can help.

  • 1
    Changing the core files is not encouraged. It also appears that the question has been answered. But the knowledge of where the options are checked is useful. – David Manners Nov 16 '13 at 15:19
1

You haven't provided the link ;).

To answer you first part of the question:

<catalog_product_view>
    <reference name="product.info.options">
        <action method="addOptionRenderer">
            <type>instagramimage</type>
            <block>webtoprint/catalog_product_view_options_type_instagramimage</block>
            <template>webtoprint/catalog/product/view/options/type/instagramimage.phtml</template>
        </action>
    </reference>
</catalog_product_view>

should be added to your xyz.xml (layout file) which should be in your theme's layout directory

  • app/design/frontend/default/{your_theme}/layout/xyz.xml (most themes are done in this way) or
  • app/design/frontend/{your_theme}/default/layout/xyz.xml (this is the right way) or
  • app/design/frontend/default/default/layout/xyz.xml (without a custom theme)

    'xyz' refers to any name which will be declared in your config.xml inside

     <layout>
        <updates>
            <webtoprint>
                  <file>xyz.xml</file>
    

tags.

This file is responsible for rendering your template in the intended place (block).

To answer the second part:

that's the Block file and will serve the values for your template file (instagramimage.phtml).

`getInfo()` is the method defined in your `Ikantam_Webtoprint_Block_Options_Type_Customview_Instagramimage` class, which will be used in the template.

To answer the next part:

put that template file instagramimage.phtml in the specified path

i.e.

app/design/frontend/your_theme/default/template/webtoprint/catalog/product/view/options/type/instagramimage.phtml

this template is displayed in the right place because of your xyz.xml in layout directory, which says <catalog_product_view> and that means the product view page.

  • You said that add the "<layout> <updates> <webtoprint> <file>xyz.xml</file>" in my config file. There is no layout tag in my config file. Can you say me where to add the code part in config.xml. – ranjitpradhan Oct 28 '13 at 13:51
  • can you post the link you followed? so that more confusions can be avoided. – Shathish Oct 29 '13 at 5:41
  • Yes, now its working. can you say me how to create a extension of own. – ranjitpradhan Oct 29 '13 at 6:21
  • glad it worked :) what do you mean by creating extension? just a custom module or an extension to be listed on magentocommerce? – Shathish Oct 29 '13 at 6:57
  • Hello Shathish, There is one more problem in the extension, It did not save the price when i store the price of that option type. Can you please say me about that. Why it is not working – ranjitpradhan Oct 30 '13 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.