2

I have created a extension with the help of "http://magento.ikantam.com/qa/custom-input-types-custom-options" link. I have change the main folder name to Nettantradevelopment and modukle name to Webtoprint.

After changed all the files i have got the error "Fatal error: Call to a member function setCanReadPrice() on a non-object in option.php.

My option.php is like

<?php
class Nettantradevelopment_Webtoprint_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option
        extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option
{
    /**
     * Class constructor
     */
    public function __construct()
    {
        parent::__construct();
        $this->setTemplate('webtoprint/catalog/product/edit/options/option.phtml');
    }
    /**
     * Retrieve html templates for different types of product custom options
     *
     * @return string
     */
    public function getTemplatesHtml()
    {
        $canEditPrice = $this->getCanEditPrice();
        $canReadPrice = $this->getCanReadPrice();

        $this->getChild('webtoprint_option_type')
            ->setCanReadPrice($canReadPrice)
            ->setCanEditPrice($canEditPrice);
        $templates = parent::getTemplatesHtml() . "\n" .
            $this->getChildHtml('webtoprint_option_type');
        return $templates;
    }
}

Here is my config file.

<?xml version="1.0"?>
<config>
  <modules>  
    <Nettantradevelopment_Webtoprint>  
     <version>0.0.1</version>  
    </Nettantradevelopment_Webtoprint>  
  </modules>
  <global>
    <catalog>
      <product>
        <options>
          <custom>
            <groups>
              <webtoprint translate="label" module="webtoprint">
                <label>Web to Print</label>
                <render>
                  webtoprint_adminhtml_catalog_product_edit_tab_options_type_webtoprint
                </render> 
                <types>
                  <webtoprint_type translate="label" module="webtoprint">
                    <label>Text</label>
                  </webtoprint_type>
                </types>
              </webtoprint>
            </groups>
          </custom>
        </options>
      </product>
    </catalog>
    <blocks>
      <adminhtml>
        <rewrite>
          <catalog_product_edit_tab_options_option>Nettantradevelopment_Webtoprint_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option</catalog_product_edit_tab_options_option>
        </rewrite>
      </adminhtml>
    </blocks>
    <models>
      <catalog>
        <rewrite>
          <product_option>Nettantradevelopment_Webtoprint_Model_Catalog_Product_Option</product_option>
        </rewrite>
      </catalog>
    </models>
    <catalog_product_view>
      <reference name="product.info.options">
        <action method="addOptionRenderer">
          <type>webtoprint</type>
          <block>webtoprint/catalog_product_view_options_type_webtoprint</block>
          <template>webtoprint/catalog/product/view/options/type/webtoprint.phtml</template>
        </action>
      </reference>
    </catalog_product_view>
  </global>
</config>

Is there anything i did wrong in the config file. In the tutorial one thing is written that "Remaining thing is to make the input type to appear on the product page. Add render to the layout file of our module:" and the xml code is

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

I dont know where i put the code ? Please help me.

3
  • 1
    please update your question with the config.xml and the layout.xml if there is one to check out if webtoprint_option_type actually exists – Sander Mangel Oct 16 '13 at 10:31
  • I have the config.xml, but not the layout.xml – ranjitpradhan Oct 17 '13 at 10:47
  • Hey, how you resolved this error i got a same error please help – Renish Khunt May 27 '15 at 13:45
1

In your code you are calling $this->getChild('webtoprint_option_type'). This means that it's trying to retrieve a block there and if it succeeds it should return an instance of the class or whatever the block class may be Nettantradevelopment_Webtoprint_Block_Option_Type.

I don't see you defining the block anywhere in your code and as you've stated you don't have a layout xml in which it is defined to the fact that the getChild function doesn't return an object is correct.

Make sure you define a block called webtoprint_option_type inside the block you are calling it from and set the proper block class for it. Once you've done that your code can perform the set methods you are calling on that class.

1

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.