1

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.

closed as off-topic by David Manners, MTM, Marius, Keyul Shah, Matthias Zeis Aug 20 '14 at 19:06

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced OR seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – David Manners, MTM, Marius, Keyul Shah, Matthias Zeis
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Any chance the issue is to do with the white space before Programmerrkt_Customfieldinbundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option in your config.xml? – David Manners Aug 20 '14 at 14:01
  • @DavidManners: Ya that was the issue. I spent lot of time (more than one week !) in order to find that error. :( It was small but BIGGEST mistake that I have made. My bad :( – Rajeev K Tomy Aug 20 '14 at 14:15
  • @DavidManners : I forgot to put that an answer. I will do it right now. Thanks for notify this :) – Rajeev K Tomy Aug 20 '14 at 14:15
  • I would suggest maybe closing it as I am not sure how much people can take away from this question. – David Manners Aug 20 '14 at 14:17
  • @DavidManners: I will close the question after put my answer :) – Rajeev K Tomy Aug 20 '14 at 14:19
1

The error that I made here was small. But it consumed my lot of time to found out it. This was the error

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

Please not the unwanted space that exist in between the node <adminhtml_catalog_product_edit_tab_bundle_option />. Correct code is this.

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

So the lesson I studied

"Even simple spaces that we leave inside config file may product serious effect. So beware simple spaces. They are dangerous"

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