Error on Magento adminhtml category tab block override

When i try to override "app\code\core\Mage\Adminhtml\Block\Catalog\Category\Tab" this Block Mage_Adminhtml_Block_Catalog_Category_Tab_Product for add new column in category product listing tab

I have get this error

Fatal error: Call to a member function toHtml() on a non-object in D:\xampp\htdocs\magento_new\app\code\core\Mage\Adminhtml\Block\Catalog\Category\Tabs.php on line 153

My code

Module config xml app\code\local\Krp\Adminhtml\etc\config.xml

<?xml version="1.0"?> <config> <modules> <Krp_Adminhtml> <version>0.1</version> </Krp_Adminhtml> </modules> <global> <blocks> <adminhtml> <rewrite> <catalog_category_tab_product>Krp_Adminhtml_Block_Catalog_Category_Tab_Product</catalog_category_tab_product> </rewrite> </adminhtml> </blocks> </global> </config>

app\etc\modules\Krp_Adminhtml.xml

<?xml version="1.0"?> <config> <modules> <Krp_Adminhtml> <active>true</active> <codePool>local</codePool> </Krp_Adminhtml> </modules> </config>

Block file code app\code\local\Krp\Adminhtml\Block\Catalog\Category\Tab\Product.php

class Krp_Adminhtml_Block_Catalog_Category_Tab_Product extends Mage_Adminhtml_Block_Catalog_Category_Tab_Product{ protected function _prepareCollection(){ //=============== Code ==================// } }

-------------Problems Reply------------

You forgot to configure the name of the block class.

config.xml

<config>
...
<global>
...
<blocks>
<krp_adminhtml>
<class>Krp_Adminhtml_Block</class>
</krp_adminhtml>

<adminhtml>
<rewrite>
<catalog_category_tab_product>Krp_Adminhtml_Block_Catalog_Category_Tab_Product</catalog_category_tab_product>
</rewrite>
</adminhtml>
</blocks>
...
</global>
...
</config>

/app/code/local/Krp/Adminhtml/Block/Adminhtml/Catalog/Category/Tab/Product.php

File should be as following :

<?php
class Krp_Adminhtml_Block_Adminhtml_Catalog_Category_Tab_Product extends Mage_Adminhtml_Block_Catalog_Category_Tab_Product
{
}

Your confing.xml should be as following :

<?xml version="1.0"?>
<config>
<modules>
<Krp_Adminhtml>
<version>1.0.0</version>
</Krp_Adminhtml>
</modules>
<global>
<helpers>
<adminhtml>
<class>Krp_Adminhtml_Helper</class>
</adminhtml>
</helpers>
<blocks>
<adminhtml>
<class>Krp_Adminhtml_Block</class>
</adminhtml>
<adminhtml>
<rewrite>
<catalog_category_tab_product>Krp_Adminhtml_Block_Adminhtml_Catalog_Category_Tab_Product</catalog_category_tab_product>
</rewrite>
</adminhtml>
</blocks>
</global>
</config>

And finally Helper class if required /app/code/local/Krp/Adminhtml/Helper/Data.php

<?php
class Krp_Adminhtml_Helper_Data extends Mage_Core_Helper_Abstract
{
}

Category:php Views:0 Time:2019-01-11

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.162 (s). 11 q(s)