|
Hello everyone!
I have a need of creating custom category tree in backend that is displayed like the original magento categories, but without need of them being edited. Now i’m at the point that i need to create the tree from my category table.
I tried to inspect the mage catalog module and found out that displaying a tree starts from ‘Varien_Data_Tree_Dbp’ class and also noticed that class ‘Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Tree’ extends ‘Varien_Data_Tree_Dbp’ class
and so tried to make my own model class extend from the ‘Varien_Data_Tree_Dbp’ class too but with no luck.
Few snippets how i’m trying to do it (i renamed the class to generic names for privacy sake)
This is my model with constructor(Similar to ...Resource_Eav_Mysql4_Category_Tree class):
class Namespace_Mymodule_Model_Customcategory extends Varien_Data_Tree_Dbp { public function __construct() { $this->_init('mymodule/customcategory'); $resource = Mage::getSingleton('core/resource');
parent::__construct( $resource->getConnection('core_write'), $resource->getTableName('mymodule/customcategory'), array( Varien_Data_Tree_Dbp::ID_FIELD => 'id', Varien_Data_Tree_Dbp::PATH_FIELD => 'path', Varien_Data_Tree_Dbp::ORDER_FIELD => 'position', Varien_Data_Tree_Dbp::LEVEL_FIELD => 'level', ) ); }
}
and with this line i try to instantiate the model in one of the adminhtml tab blocks:
$tree = Mage::getModel('mymodule/customcategory');
But everytime i try to instantiate it i’m just getting a blank screen, no error messages or anything.
Can i actually extend Varien_Data_Tree_Dbp class like this (well magento did it with resource model class so why couldn’t i?)?
Am I even going the right way considering that my goal is to create possibility to display categories in tree view in backend and source them from custom table?
I’m stuck, so any help is highly appreciated.
|