Public Member Functions | |
__construct () | |
getCategory () | |
getCategoryId () | |
getCategoryName () | |
getCategoryPath () | |
hasStoreRootCategory () | |
getStore () | |
getRoot ($parentNodeCategory=null, $recursionLevel=3) | |
getRootByIds ($ids) | |
getNode ($parentNodeCategory, $recursionLevel=2) | |
getSaveUrl (array $args=array()) | |
getEditUrl () |
Definition at line 34 of file Abstract.php.
__construct | ( | ) |
Constructor
By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes
Reimplemented from Varien_Object.
Reimplemented in Mage_Adminhtml_Block_Catalog_Category_Edit_Form, Mage_Adminhtml_Block_Catalog_Category_Tree, Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Categories, and Mage_Adminhtml_Block_Urlrewrite_Category_Tree.
Definition at line 37 of file Abstract.php.
00038 { 00039 parent::__construct(); 00040 }
getCategory | ( | ) |
Definition at line 42 of file Abstract.php.
00043 { 00044 return Mage::registry('category'); 00045 }
getCategoryId | ( | ) |
Definition at line 47 of file Abstract.php.
00048 { 00049 if ($this->getCategory()) { 00050 return $this->getCategory()->getId(); 00051 } 00052 return Mage_Catalog_Model_Category::TREE_ROOT_ID; 00053 }
getCategoryName | ( | ) |
Definition at line 55 of file Abstract.php.
00056 { 00057 return $this->getCategory()->getName(); 00058 }
getCategoryPath | ( | ) |
Definition at line 60 of file Abstract.php.
00061 { 00062 if ($this->getCategory()) { 00063 return $this->getCategory()->getPath(); 00064 } 00065 return Mage_Catalog_Model_Category::TREE_ROOT_ID; 00066 }
getEditUrl | ( | ) |
Definition at line 180 of file Abstract.php.
00181 { 00182 return $this->getUrl("*/catalog_category/edit", array('_current'=>true, 'store'=>null, '_query'=>false, 'id'=>null, 'parent'=>null)); 00183 }
getNode | ( | $ | parentNodeCategory, | |
$ | recursionLevel = 2 | |||
) |
Definition at line 152 of file Abstract.php.
00153 { 00154 $tree = Mage::getResourceModel('catalog/category_tree'); 00155 00156 $nodeId = $parentNodeCategory->getId(); 00157 $parentId = $parentNodeCategory->getParentId(); 00158 00159 $node = $tree->loadNode($nodeId); 00160 $node->loadChildren($recursionLevel); 00161 00162 if ($node && $nodeId != Mage_Catalog_Model_Category::TREE_ROOT_ID) { 00163 $node->setIsVisible(true); 00164 } elseif($node && $node->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID) { 00165 $node->setName(Mage::helper('catalog')->__('Root')); 00166 } 00167 00168 $tree->addCollectionData($this->getCategoryCollection()); 00169 00170 return $node; 00171 }
getRoot | ( | $ | parentNodeCategory = null , |
|
$ | recursionLevel = 3 | |||
) |
Reimplemented in Mage_Adminhtml_Block_Catalog_Category_Checkboxes_Tree, and Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Categories.
Definition at line 83 of file Abstract.php.
00084 { 00085 if (!is_null($parentNodeCategory) && $parentNodeCategory->getId()) { 00086 return $this->getNode($parentNodeCategory, $recursionLevel); 00087 } 00088 $root = Mage::registry('root'); 00089 if (is_null($root)) { 00090 $storeId = (int) $this->getRequest()->getParam('store'); 00091 00092 if ($storeId) { 00093 $store = Mage::app()->getStore($storeId); 00094 $rootId = $store->getRootCategoryId(); 00095 } 00096 else { 00097 $rootId = Mage_Catalog_Model_Category::TREE_ROOT_ID; 00098 } 00099 00100 $tree = Mage::getResourceSingleton('catalog/category_tree') 00101 ->load($rootId, $recursionLevel); 00102 00103 if ($this->getCategory()) { 00104 $tree->loadEnsuredNodes($this->getCategory(), $tree->getNodeById($rootId)); 00105 } 00106 00107 $tree->addCollectionData($this->getCategoryCollection()); 00108 00109 $root = $tree->getNodeById($rootId); 00110 00111 if ($root && $rootId != Mage_Catalog_Model_Category::TREE_ROOT_ID) { 00112 $root->setIsVisible(true); 00113 } 00114 elseif($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID) { 00115 $root->setName(Mage::helper('catalog')->__('Root')); 00116 } 00117 00118 Mage::register('root', $root); 00119 } 00120 00121 return $root; 00122 }
getRootByIds | ( | $ | ids | ) |
Get and register categories root by specified categories IDs
IDs can be arbitrary set of any categories ids. Tree with minimal required nodes (all parents and neighbours) will be built. If ids are empty, default tree with depth = 2 will be returned.
array | $ids |
Definition at line 133 of file Abstract.php.
00134 { 00135 $root = Mage::registry('root'); 00136 if (null === $root) { 00137 $tree = Mage::getResourceSingleton('catalog/category_tree') 00138 ->loadByIds($ids); 00139 $rootId = Mage_Catalog_Model_Category::TREE_ROOT_ID; 00140 $root = $tree->getNodeById($rootId); 00141 if ($root && $rootId != Mage_Catalog_Model_Category::TREE_ROOT_ID) { 00142 $root->setIsVisible(true); 00143 } 00144 elseif($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID) { 00145 $root->setName(Mage::helper('catalog')->__('Root')); 00146 } 00147 Mage::register('root', $root); 00148 } 00149 return $root; 00150 }
Definition at line 173 of file Abstract.php.
00174 { 00175 $params = array('_current'=>true); 00176 $params = array_merge($params, $args); 00177 return $this->getUrl('*/*/save', $params); 00178 }
getStore | ( | ) |
Definition at line 77 of file Abstract.php.
00078 { 00079 $storeId = (int) $this->getRequest()->getParam('store'); 00080 return Mage::app()->getStore($storeId); 00081 }
hasStoreRootCategory | ( | ) |
Definition at line 68 of file Abstract.php.
00069 { 00070 $root = $this->getRoot(); 00071 if ($root && $root->getId()) { 00072 return true; 00073 } 00074 return false; 00075 }