Adding Custom Tab in category tab product adminhtml

I have create a custom module in Magento ver. 1.9.3.6 and this module adding a new tab in category tab product admin area but it’s not working.

Namespace/ModuleName/Block/Catalog/Category/Tab/Product

  <?php     /**      * Magento      *      * NOTICE OF LICENSE      *      * This source file is subject to the Open Software License (OSL 3.0)      * that is bundled with this package in the file LICENSE.txt.      * It is also available through the world-wide-web at this URL:      * http://opensource.org/licenses/osl-3.0.php      * If you did not receive a copy of the license and are unable to      * obtain it through the world-wide-web, please send an email      * to license@magento.com so we can send you a copy immediately.      *      * DISCLAIMER      *      * Do not edit or add to this file if you wish to upgrade Magento to newer      * versions in the future. If you wish to customize Magento for your      * needs please refer to http://www.magento.com for more information.      *      * @category    Mage      * @package     Mage_Adminhtml      * @copyright  Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)      * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)      */      /**      * Product in category grid      *      * @category   Mage      * @package    Mage_Adminhtml      * @author      Magento Core Team <core@magentocommerce.com>      */     class Namespace_ModuleName_Block_Catalog_Category_Tab_Product extends Mage_Adminhtml_Block_Catalog_Category_Tab_Product     {          public function __construct()         {             Mage_Adminhtml_Block_Widget_Grid::__construct();             $  this->setId('catalog_category_products');             $  this->setDefaultSort('entity_id');             $  this->setUseAjax(true);         }          public function getCategory()         {             return Mage::registry('category');         }          protected function _addColumnFilterToCollection($  column)         {             // Set custom filter for in category flag             if ($  column->getId() == 'in_category') {                 $  productIds = $  this->_getSelectedProducts();                 if (empty($  productIds)) {                     $  productIds = 0;                 }                 if ($  column->getFilter()->getValue()) {                     $  this->getCollection()->addFieldToFilter('entity_id', array('in'=>$  productIds));                 }                 elseif(!empty($  productIds)) {                     $  this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$  productIds));                 }             }             else {                 Mage_Adminhtml_Block_Widget_Grid::_addColumnFilterToCollection($  column);             }             return $  this;         }          protected function _prepareCollection()         {             if ($  this->getCategory()->getId()) {                 $  this->setDefaultFilter(array('in_category'=>1));             }             $  collection = Mage::getModel('catalog/product')->getCollection()                 ->addAttributeToSelect('name')                 ->addAttributeToSelect('sku')                 ->addAttributeToSelect('package_name')                 ->addAttributeToSelect('size_name')                 ->addAttributeToSelect('price')                 ->addStoreFilter($  this->getRequest()->getParam('store'))                 ->joinField('position',                     'catalog/category_product',                     'position',                     'product_id=entity_id',                     'category_id='.(int) $  this->getRequest()->getParam('id', 0),                     'left');             $  this->setCollection($  collection);              if ($  this->getCategory()->getProductsReadonly()) {                 $  productIds = $  this->_getSelectedProducts();                 if (empty($  productIds)) {                     $  productIds = 0;                 }                 $  this->getCollection()->addFieldToFilter('entity_id', array('in'=>$  productIds));             }              return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();         }          protected function _prepareColumns()         {             if (!$  this->getCategory()->getProductsReadonly()) {                 $  this->addColumn('in_category', array(                     'header_css_class' => 'a-center',                     'type'      => 'checkbox',                     'name'      => 'in_category',                     'values'    => $  this->_getSelectedProducts(),                     'align'     => 'center',                     'index'     => 'entity_id'                 ));             }             $  this->addColumn('entity_id', array(                 'header'    => Mage::helper('catalog')->__('ID'),                 'sortable'  => true,                 'width'     => '60',                 'index'     => 'entity_id'             ));             $  this->addColumn('name', array(                 'header'    => Mage::helper('catalog')->__('Name'),                 'index'     => 'name'             ));             $  this->addColumn('sku', array(                 'header'    => Mage::helper('catalog')->__('SKU'),                 'width'     => '80',                 'index'     => 'sku'             ));  // New Tab             $  package_attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'package_name');             $  packages = array();             foreach( $  package_attribute->getSource()->getAllOptions(true, true) as $  option ) {                 if($  option['label'])                 {                     $  packages[$  option['value']] = $  option['label'];                 }             }             $  this->addColumn('package_name', array(                 'header'    => Mage::helper('catalog')->__('Package'),                 'type'  => 'options',                 'index'     => 'package_name',                 'options' => $  packages             ));             $  size_attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'size_name');             $  sizes = array();             foreach( $  size_attribute->getSource()->getAllOptions(true, true) as $  option ) {                 if($  option['label'])                 {                    $  sizes[$  option['value']] = $  option['label'];                 }             }             $  this->addColumn('size_name', array(                 'header'    => Mage::helper('catalog')->__('Size'),                 'type'  => 'options',                 'index'     => 'size_name',                 'options' => $  sizes             ));             $  this->addColumn('sku', array(                 'header'    => Mage::helper('catalog')->__('SKU'),                 'width'     => '80',                 'index'     => 'sku'             ));             $  this->addColumn('price', array(                 'header'    => Mage::helper('catalog')->__('Price'),                 'type'  => 'currency',                 'width'     => '1',                 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),                 'index'     => 'price'             ));             $  this->addColumn('position', array(                 'header'    => Mage::helper('catalog')->__('Position'),                 'width'     => '1',                 'type'      => 'number',                 'index'     => 'position',                 'editable'  => !$  this->getCategory()->getProductsReadonly()                 //'renderer'  => 'adminhtml/widget_grid_column_renderer_input'             ));              return Mage_Adminhtml_Block_Widget_Grid::_prepareColumns();         }          public function getGridUrl()         {             return $  this->getUrl('*/*/grid', array('_current'=>true));         }          protected function _getSelectedProducts()         {             $  products = $  this->getRequest()->getPost('selected_products');             if (is_null($  products)) {                 $  products = $  this->getCategory()->getProductsPosition();                 return array_keys($  products);             }             return $  products;         }      } 

Namespace/ModuleName//etc/config.xml

<?xml version="1.0" ?> <config>     <modules>         <Namespace_ModuleName/>             <version>1.0</version>         </Namespace_ModuleName/>     </modules>     <global>         <blocks>             <namespace_modulename/>                     <class>Namespace_ModuleName_Block</class>             </namespace_modulename>             <adminhtml>                 <rewrite>                     <catalog_category_tab_product>Namespace_ModuleName_Block_Catalog_Category_Tab_Product</catalog_category_tab_product>                 </rewrite>             </adminhtml>         </blocks>     </global> </config> 

etc/modules/Namespace_ModuleName.xml

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

but it’s not working so any suggestions please?

Error Message:

Fatal error: Call to a member function toHtml() on boolean in includes/src/Mage_Adminhtml_Block_Catalog_Category_Tabs.php on line 153