当前位置: 首页>>代码示例>>PHP>>正文


PHP Varien_Data_Tree_Node::getData方法代码示例

本文整理汇总了PHP中Varien_Data_Tree_Node::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Tree_Node::getData方法的具体用法?PHP Varien_Data_Tree_Node::getData怎么用?PHP Varien_Data_Tree_Node::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Varien_Data_Tree_Node的用法示例。


在下文中一共展示了Varien_Data_Tree_Node::getData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: nodeToArray

 private function nodeToArray(Varien_Data_Tree_Node $node, $mediaUrl, $baseUrl)
 {
     $result = array();
     $thumbnail = '';
     try {
         $thumbImg = $node->getThumbnail();
         if ($thumbImg != null) {
             $thumbnail = $mediaUrl . 'catalog/category/' . $node->getThumbnail();
         }
     } catch (Exception $e) {
     }
     $result['category_id'] = $node->getId();
     $result['image'] = $mediaUrl . 'catalog/category/' . $node->getImage();
     $result['thumbnail'] = $thumbnail;
     $result['description'] = strip_tags($node->getDescription());
     $result['parent_id'] = $node->getParentId();
     $result['name'] = $node->getName();
     $result['is_active'] = $node->getIsActive();
     $result['children'] = array();
     if (method_exists('Mage', 'getEdition') && Mage::getEdition() == Mage::EDITION_COMMUNITY) {
         $result['url_path'] = $baseUrl . $node->getData('url_path');
     } else {
         $category = Mage::getModel('catalog/category')->load($node->getId());
         $result['url_path'] = $category->getUrl();
     }
     foreach ($node->getChildren() as $child) {
         $result['children'][] = $this->nodeToArray($child, $mediaUrl, $baseUrl);
     }
     return $result;
 }
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:30,代码来源:CategoriesController.php

示例2: _getNodeJson

 /**
  * Get JSON of a tree node or an associative array
  *
  * @param Varien_Data_Tree_Node|array $node
  * @param int $level
  * @return string
  */
 protected function _getNodeJson($node, $level = 1)
 {
     $item = array();
     $item['text'] = $this->htmlEscape($node->getName());
     if ($this->_withProductCount) {
         $item['text'] .= ' (' . $node->getProductCount() . ')';
     }
     $item['id'] = $node->getId();
     $item['path'] = $node->getData('path');
     $item['cls'] = 'folder ' . ($node->getIsActive() ? 'active-category' : 'no-active-category');
     $item['allowDrop'] = false;
     $item['allowDrag'] = false;
     if ($node->hasChildren()) {
         $item['children'] = array();
         foreach ($node->getChildren() as $child) {
             $item['children'][] = $this->_getNodeJson($child, $level + 1);
         }
     }
     if (empty($item['children']) && (int) $node->getChildrenCount() > 0) {
         $item['children'] = array();
     }
     if (!empty($item['children'])) {
         $item['expanded'] = true;
     }
     if (in_array($node->getId(), $this->getCategoryIds())) {
         $item['checked'] = true;
     }
     return $item;
 }
开发者ID:CopeX,项目名称:BannerSlider-Magento,代码行数:36,代码来源:Categories.php

示例3: _isCategoryClickAble

 /**
  * Check if click able enabled for category.
  *
  * @param Varien_Data_Tree_Node|Mage_Catalog_Model_Category $category
  * @return bool
  */
 protected function _isCategoryClickAble($category)
 {
     $isCategoryClickAbleStatus = true;
     $isCategoryClickAble = $category->getData(Monsoon_Test_Helper_Data::IS_CLICK_ABLE_LINK_CODE);
     if ($isCategoryClickAble !== null && (bool) $isCategoryClickAble === false) {
         $isCategoryClickAbleStatus = false;
     }
     return $isCategoryClickAbleStatus;
 }
开发者ID:sergiozt,项目名称:monsoon,代码行数:15,代码来源:Observer.php

示例4: _addChildNodes

 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);
         }
     }
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:29,代码来源:Dbp.php

示例5: _getProductCount

 /**
  * Return the number of products assigned to the category
  *
  * @param Mage_Catalog_Model_Category|Varien_Data_Tree_Node $category
  * @return int
  */
 protected function _getProductCount($category)
 {
     if (null === ($count = $category->getData('product_count'))) {
         $count = 0;
         if ($category instanceof Mage_Catalog_Model_Category) {
             $count = $category->getProductCount();
         } elseif ($category instanceof Varien_Data_Tree_Node) {
             $count = $this->_getProductCountFromTreeNode($category);
         }
     }
     return $count;
 }
开发者ID:gruenspar,项目名称:VertNav,代码行数:18,代码来源:Navigation.php

示例6: moveNodeTo

 /**
  * Move tree node
  *
  * @param Varien_Data_Tree_Node $node
  * @param Varien_Data_Tree_Node $parentNode
  * @param Varien_Data_Tree_Node $prevNode
  */
 public function moveNodeTo($node, $parentNode, $prevNode = null)
 {
     $data = array();
     $data[$this->_parentField] = $parentNode->getId();
     $data[$this->_levelField] = $parentNode->getData($this->_levelField) + 1;
     // New node order
     if (is_null($prevNode) || is_null($prevNode->getData($this->_orderField))) {
         $data[$this->_orderField] = 1;
     } else {
         $data[$this->_orderField] = $prevNode->getData($this->_orderField) + 1;
     }
     $condition = $this->_conn->quoteInto("{$this->_idField}=?", $node->getId());
     // For reorder new node branch
     $dataReorderNew = array($this->_orderField => new Zend_Db_Expr($this->_conn->quoteIdentifier($this->_orderField) . '+1'));
     $conditionReorderNew = $this->_conn->quoteIdentifier($this->_parentField) . '=' . $parentNode->getId() . ' AND ' . $this->_conn->quoteIdentifier($this->_orderField) . '>=' . $data[$this->_orderField];
     // For reorder old node branch
     $dataReorderOld = array($this->_orderField => new Zend_Db_Expr($this->_conn->quoteIdentifier($this->_orderField) . '-1'));
     $conditionReorderOld = $this->_conn->quoteIdentifier($this->_parentField) . '=' . $node->getData($this->_parentField) . ' AND ' . $this->_conn->quoteIdentifier($this->_orderField) . '>' . $node->getData($this->_orderField);
     $this->_conn->beginTransaction();
     try {
         // Prepare new node branch
         $this->_conn->update($this->_table, $dataReorderNew, $conditionReorderNew);
         // Move node
         $this->_conn->update($this->_table, $data, $condition);
         // Update old node branch
         $this->_conn->update($this->_table, $dataReorderOld, $conditionReorderOld);
         $this->_updateChildLevels($node->getId(), $data[$this->_levelField]);
         $this->_conn->commit();
     } catch (Exception $e) {
         $this->_conn->rollBack();
         throw new Exception('Can\'t move tree node');
     }
 }
开发者ID:relue,项目名称:magento2,代码行数:40,代码来源:Db.php

示例7: move

 /**
  * Move tree node
  *
  * @param Varien_Data_Tree_Node $node
  * @param Varien_Data_Tree_Node $parentNode
  * @param Varien_Data_Tree_Node $prevNode
  */
 public function move($category, $newParent, $prevNode = null)
 {
     $position = 1;
     $oldPath = $category->getData($this->_pathField);
     $newPath = $newParent->getData($this->_pathField);
     $newPath = $newPath . '/' . $category->getId();
     $oldPathLength = strlen($oldPath);
     $data = array($this->_pathField => new Zend_Db_Expr("CONCAT('{$newPath}', RIGHT({$this->_pathField}, LENGTH({$this->_pathField}) - {$oldPathLength}))"));
     $condition = $this->_conn->quoteInto("{$this->_pathField} REGEXP ?", "^{$oldPath}(/|\$)");
     $this->_conn->beginTransaction();
     try {
         if ($prevNode && $prevNode->getId()) {
             $reorderData = array($this->_orderField => new Zend_Db_Expr("{$this->_orderField} + 1"));
             $reorderCondition = "{$this->_orderField} > {$prevNode->getData($this->_orderField)}";
             $this->_conn->update($this->_table, $reorderData, $reorderCondition);
             $position = $prevNode->getData($this->_orderField) + 1;
         }
         $this->_conn->update($this->_table, $data, $condition);
         $this->_conn->update($this->_table, array($this->_orderField => $position), $this->_conn->quoteInto("{$this->_idField} = ?", $category->getId()));
         $this->_conn->commit();
     } catch (Exception $e) {
         $this->_conn->rollBack();
         throw new Exception("Can't move tree node due to error: " . $e->getMessage());
     }
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:32,代码来源:Dbp.php

示例8: getNodeChildrenData

function getNodeChildrenData(Varien_Data_Tree_Node $node)
{
    foreach ($node->getChildren() as $childNode) {
        $result[] = array('category_id' => $childNode->getData('entity_id'), 'parent_id' => $node->getData('entity_id'), 'name' => $childNode->getData('name'), 'categories' => getNodeChildrenData($childNode));
    }
    return $result;
}
开发者ID:imromec,项目名称:magento-android-web-api,代码行数:7,代码来源:web-api.php


注:本文中的Varien_Data_Tree_Node::getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。