0

I'm new to M1. I'm trying to add a new custom option type in product

My Config

<?xml version="1.0"?>
<config>
<modules>
    <CompanyName_ModuleName>
        <version>0.1.0</version>
    </CompanyName_ModuleName>
</modules>   
<global>
    <blocks>
        <adminhtml>
            <rewrite>
                <catalog_product_edit_tab_options_option>CompanyName_ModuleName_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option</catalog_product_edit_tab_options_option>
            </rewrite>
        </adminhtml>
        <modulename>
            <class>CompanyName_ModuleName_Block</class>
        </modulename>
    </blocks>
    <catalog>
        <product>
            <options>
                <custom>
                    <groups>
                        <modulename translate="label" module="modulename">
                            <label>Special Types</label>
                            <render>CompanyName_ModuleName_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Type_Stone</render>
                            <types>
                                <stone translate="label" module="modulename">
                                    <label>Stone</label>
                                </stone>
                            </types>
                        </modulename>
                    </groups>
                </custom>
            </options>
        </product>
    </catalog>
    <models>
        <catalog>
            <rewrite>
                <product_option>CompanyName_ModuleName_Model_Catalog_Product_Option</product_option>
            </rewrite>
        </catalog>
    </models>
    <catalog_product_view>
        <reference name="product.info.options">
            <action method="addOptionRenderer">
                <type>stone</type>
                <block>modulename/catalog_product_view_options_type_stone</block>
                <template>companyname/modulename/catalog/product/view/options/type/stone.phtml</template>
            </action>
        </reference>
    </catalog_product_view>
</global> 
<frontend>
    <routers>
        <CompanyName_ModuleName_Router>
            <use>standard</use>
            <args>
                <module>CompanyName_ModuleName</module>
                <frontName>modulename</frontName>
            </args>
        </CompanyName_ModuleName_Router>
    </routers>
</frontend>

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <companyname_modulename after="Mage_Adminhtml">CompanyName_ModuleName_Adminhtml</companyname_modulename>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>
</config>

My Block

class CompanyName_ModuleName_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Type_Stone extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Abstract
{
public function __construct()
{
    parent::__construct();
    $this->setTemplate('companyname/modulename/catalog/product/edit/options/type/stone.phtml');
    //var_dump($this->hasData('template'));exit;
    $this->setCanEditPrice(true);
    $this->setCanReadPrice(true);
}
}

In my phtml file I var_dump something to test but it doesn't work. var_dump in the block works. And i put my phtml in

design/adminhtml/default/default/template/companyname/modulename/catalog/product/edit/options/type/stone.phtml

Did I do somthing wrong? Any help would be very appreciated.

Thanks.

1 Answer 1

0

you can call phtml file by using below code

1) call phtml via block file

class CompanyName_ModuleName_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Type_Stone extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Abstract
{
    public function __construct()
    {
        parent::__construct();
        $this->setTemplate('modulename/catalog/product/edit/options/type/stone.phtml');
    }
}

your template file should be in

design/adminhtml/default/default/template/modulename/catalog/product/edit/options/type/stone.phtml

2
  • I tried, but it still doesn't seem to work.
    – Baodoan
    Commented Oct 18, 2018 at 6:48
  • make sure Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Abstract class should override properly into local file, or try just testing purpose into core file
    – Hitesh
    Commented Oct 18, 2018 at 6:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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