0

Magento CE 1.9.2.2

I would like to rewrite Mage_Adminhtml_Block_Catalog_Product_Edit.

Specifically this file: app/code/Mage/Adminhtml/Block/Catalog/Product/Edit.php

In my custom module's etc/config.xml file I have this for the rewrite block (not actually MyCompany/MyModule):

<adminhtml>
  <rewrite>
    <catalog_product_edit>MyCompany_MyModule_Block_Adminhtml_Catalog_Product_Edit</catalog_product_edit>
  </rewrite>
</adminhtml>

But where this approach has worked before for overwriting other blocks, I'm now getting this PHP error:

PHP Fatal error:  Class 'MyCompany_MyModule_Block_Adminhtml_Catalog_Product_Edit' not found in /var/www/html/app/code/core/Mage/Core/Model/Layout.php on line 491

I think my config.xml rewrite entry might be at fault but I'm not certain.

  • Please check at module main config. MyCompany_MyModule.xml add your system not check compiler is enabled ornot – Amit Bera May 10 '16 at 18:35
  • From the error, it looks like your configuration is working fine, and the class file can be found from the system. You probably have some sort of syntax error in your PHP file (maybe a typo in your class name? Or upper/lowercase naming issue?). What happens if you manually require your file? – fmrng May 10 '16 at 21:49
0

Check below code, may be this will help you out.
Config.xml for rewrite

<?xml version="1.0"?>
<config>
<modules>
    <My_Custom>
    <version>0.1.0</version>
    </My_Custom>
</modules>
<global>
    <blocks>
        <custom>
            <class>My_Custom_Block</class>
        </custom>
        <adminhtml>
           <rewrite>
               <catalog_product_grid>My_Custom_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
           </rewrite>
       </adminhtml>
    </blocks>
</global>
</config>

Code for extending class

class My_Custom_Block_Adminhtml_Catalog_Product_Edit extends Mage_Adminhtml_Block_Catalog_Product_Edit {

}

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.