예제 #1
0
 protected function _addChildNodes($children, $path, $parentNode, $withChildren = false, $level = 0)
 {
     if (isset($children[$path])) {
         foreach ($children[$path] as $child) {
             $nodeId = isset($child[$this->_idField]) ? $child[$this->_idField] : false;
             if ($parentNode && $nodeId && ($node = $parentNode->getChildren()->searchById($nodeId))) {
                 $node->addData($child);
             } else {
                 $node = new Varien_Data_Tree_Node($child, $this->_idField, $this, $parentNode);
                 $node->setLevel($node->getData($this->_levelField));
                 $node->setPathId($node->getData($this->_pathField));
                 $this->addNode($node, $parentNode);
             }
             if ($withChildren) {
                 $this->_loaded = false;
                 $node->loadChildren(1);
                 $this->_loaded = false;
             }
             if ($path) {
                 $childrenPath = explode('/', $path);
             } else {
                 $childrenPath = array();
             }
             $childrenPath[] = $node->getId();
             $childrenPath = implode('/', $childrenPath);
             $this->_addChildNodes($children, $childrenPath, $node, $withChildren, $level + 1);
         }
     }
 }
예제 #2
0
 public function addChildNodes($children, $path, $parentNode, $level = 0)
 {
     if (isset($children[$path])) {
         foreach ($children[$path] as $child) {
             $node = new Varien_Data_Tree_Node($child, $this->_idField, $this, $parentNode);
             $node->setLevel(count(explode('/', $node->getData($this->_pathField))));
             $node->setPathId($node->getData($this->_pathField));
             $this->addNode($node, $parentNode);
             if ($path) {
                 $childrenPath = explode('/', $path);
             } else {
                 $childrenPath = array();
             }
             $childrenPath[] = $node->getId();
             $childrenPath = implode('/', $childrenPath);
             $this->addChildNodes($children, $childrenPath, $node, $level + 1);
         }
     }
 }