Question

I am creating a module that will add a custom field for bundle product. For that I came to a situation in which, I have to overwrite the core block Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option. However my overwriting seems to be not working.

More specific to the problem, I need to overwrite

  1. __construct() - This method is using to set the template that is need to render for options (When we click on Add Options under tab Bundle Items in bundle product edit page, this template is going to render). Currently it is set to template app/desig/frontend/<package>/<theme>/bundle/product/edit/bundle/option.phtml. I need to set it to a custom option.phtml file so that I can add my custom field without altering any code in core files.

  2. getOptions() - need to edit this function also. This is also essential, since I need to set details of my custom field along with details of existing fields in this function.

What I have tried

etc/config.xml

 <config>
     ----
     <global>
         ------
         <blocks>
             <bundle>
                 <rewrite>
                     <adminhtml_catalog_product_edit_tab_bundle_option>
                           Programmerrkt_Customfieldinbundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option
                    </adminhtml_catalog_product_edit_tab_bundle_option>
                </rewrite>
             </bundle>  
     </global>
 </config>

Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php

 <?php
Programmerrkt_Customfieldinbundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option extends Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option 
{

    /**
     * Bundle option renderer class constructor
     *
     * Sets block template and necessary data
     */
    public function __construct()
    {

        $this->setTemplate('programmerrkt/customfieldinbundle/bundle/product/edit/bundle/option.phtml');
        $this->setCanReadPrice(true);
        $this->setCanEditPrice(true);
    }
}

However this overwriting seems to be not working.After including this code in my module, when I click on Add Options, the button is not working at all.

So my question is,

what should I do if I want to alter this default class ?

Whether I am in right direction ?

Is it even possible to do this ?

Eagerly waiting for responses. Thanks.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top