本文整理汇总了PHP中Varien_Data_Tree_Node::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Tree_Node::getId方法的具体用法?PHP Varien_Data_Tree_Node::getId怎么用?PHP Varien_Data_Tree_Node::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Tree_Node
的用法示例。
在下文中一共展示了Varien_Data_Tree_Node::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例3: BuildBranch
public function BuildBranch(Varien_Data_Tree_Node $node)
{
$buildString = '<li style="padding-left: 16px;">';
$buildString .= '<div class="tree-level-' . $node->getLevel() . '">';
if ($node->getChildrenCount() != 0) {
$buildString .= '<div class="opener" id="opener' . $node->getId() . '" OnClick="OpenMe(this)"></div>';
} else {
$buildString .= '<div class="child"></div>';
}
$buildString .= '
<input type="checkbox" class="inputcb" id="inputcb' . $node->getId() . '" OnClick="Decide(this)" enabled="false"/>
<div class="folder"></div>
<a tabindex="1" href="#" hidefocus="on" id="linkItem"><span unselectable="on" id="extdd-' . $node->getLevel() . '">' . $node->getName() . '</a>
';
$buildString .= '</div>';
if ($node->getChildrenCount() != 0) {
$buildString .= '<ul id="ToOpen' . $node->getId() . '">';
foreach ($node->getChildren() as $child) {
$buildString .= $this->BuildBranch($child);
}
$buildString .= '</ul>';
}
$buildString .= '</li>';
return $buildString;
}
示例4: buildCategoriesMultiselectValues
public function buildCategoriesMultiselectValues(Varien_Data_Tree_Node $node, $values, $level = 0)
{
$level++;
$values[$node->getId()]['value'] = $node->getId();
$values[$node->getId()]['label'] = str_repeat("--", $level) . $node->getName();
foreach ($node->getChildren() as $child) {
$values = $this->buildCategoriesMultiselectValues($child, $values, $level);
}
return $values;
}
示例5: _buildCategoriesValues
/**
* @param Varien_Data_Tree_Node $node
* @param array $values
* @param int $level
* @return array
*/
protected function _buildCategoriesValues(Varien_Data_Tree_Node $node, $values, $level = 0)
{
++$level;
$values[$node->getId()]['value'] = $node->getId();
$values[$node->getId()]['label'] = str_repeat('--', $level) . $node->getName();
foreach ($node->getChildren() as $child) {
$values = $this->_buildCategoriesValues($child, $values, $level);
}
return $values;
}
示例6: buildCategoriesMultiselectValues
public function buildCategoriesMultiselectValues(Varien_Data_Tree_Node $node, $values, $level = 0)
{
$nonEscapableNbspChar = html_entity_decode(' ', ENT_NOQUOTES, 'UTF-8');
$level++;
$values[$node->getId()]['value'] = $node->getId();
$values[$node->getId()]['label'] = str_repeat($nonEscapableNbspChar, ($level - 1) * 5) . $node->getName();
foreach ($node->getChildren() as $child) {
$values = $this->buildCategoriesMultiselectValues($child, $values, $level);
}
return $values;
}
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:11,代码来源:Glace_Menu_Model_System_Config_Source_Category.php
示例7: buildCategoriesMultiselectValues
public function buildCategoriesMultiselectValues(Varien_Data_Tree_Node $node, $values, $level = 0)
{
$level++;
if ($level == 3) {
//we have to show only third level category in drop down
$values[$node->getId()]['value'] = $node->getId();
$values[$node->getId()]['label'] = $node->getName();
}
foreach ($node->getChildren() as $child) {
$values = $this->buildCategoriesMultiselectValues($child, $values, $level);
}
return $values;
}
示例8: nodeToArray
private function nodeToArray(Varien_Data_Tree_Node $node)
{
$result = array();
$category = Mage::getModel('catalog/category')->load($node->getId());
if ($category->getAvailableForSupplier() == 1) {
$result['category_id'] = $node->getId();
$result['parent_id'] = $node->getParentId();
$result['name'] = $node->getName();
$result['is_active'] = $node->getIsActive();
$result['position'] = $node->getPosition();
$result['level'] = $node->getLevel();
}
$result['children'] = array();
foreach ($node->getChildren() as $child) {
$result['children'][] = $this->nodeToArray($child);
}
return $result;
}
示例9: add
/**
* Adds a node to this node
*/
public function add(Varien_Data_Tree_Node $node)
{
$node->setParent($this->_container);
// Set the Tree for the node
if ($this->_container->getTree() instanceof Varien_Data_Tree) {
$node->setTree($this->_container->getTree());
}
$this->_nodes[$node->getId()] = $node;
return $node;
}
示例10: _exportProductCollection
/**
* Export product collection
*
* @param Varien_Data_Tree_Node $category
*/
protected function _exportProductCollection($category)
{
$categoryModel = Mage::getModel('catalog/category')->load($category->getId());
$this->setCategory($categoryModel)->setLayer(Mage::getSingleton('catalog/layer'));
foreach ($this->_getProductCollection() as $product) {
$product->load($product->getEntityId());
Mage::app()->getRequest()->setParam('id', $product->getId());
$this->_getExportModel(self::TYPE_PRODUCT)->setProduct($product)->exportData();
$this->_getExportModel(self::TYPE_GALLERY)->setProduct($product)->exportData();
$this->_getExportModel(self::TYPE_REVIEW)->setProduct($product)->exportData();
}
}
示例11: _isActiveMenuCategory
/**
* Checks whether category belongs to active category's path
*
* @param Varien_Data_Tree_Node $category
* @return bool
*/
protected function _isActiveMenuCategory($category)
{
$catalogLayer = Mage::getSingleton('catalog/layer');
if (!$catalogLayer) {
return false;
}
$currentCategory = $catalogLayer->getCurrentCategory();
if (!$currentCategory) {
return false;
}
$categoryPathIds = explode(',', $currentCategory->getPathInStore());
return in_array($category->getId(), $categoryPathIds);
}
示例12: nodeToArray
function nodeToArray(Varien_Data_Tree_Node $node)
{
$result = array();
$result['category_id'] = $node->getId();
$result['parent_id'] = $node->getParentId();
$result['name'] = $node->getName();
$result['is_active'] = $node->getIsActive();
$result['position'] = $node->getPosition();
$result['level'] = $node->getLevel();
$result['children'] = array();
foreach ($node->getChildren() as $child) {
$result['children'][] = $this->nodeToArray($child);
}
return $result;
}
示例13: _nodeToArrayPath
/**
* Convert node to array with path information.
* Path information skips the 'Root Catalog' (level=0) and 'Default Category' (level=1) levels.
*
* @param Varien_Data_Tree_Node $node
* @return array
*/
protected function _nodeToArrayPath(Varien_Data_Tree_Node $node, $parentPath)
{
// Only basic category data
$categories = array();
$category = array();
$category['category_id'] = $node->getId();
$category['parent_id'] = $node->getParentId();
$category['name'] = $node->getName();
$category['path'] = !empty($parentPath) && $node->getLevel() > 2 ? $parentPath . '/' . $node->getName() : $node->getName();
$category['is_active'] = $node->getIsActive();
$category['position'] = $node->getPosition();
$category['level'] = $node->getLevel();
$categories[] = $category;
foreach ($node->getChildren() as $child) {
$children = $this->_nodeToArrayPath($child, $category['path']);
$categories = array_merge($categories, $children);
}
return $categories;
}
示例14: _getNodesArray
/**
* Convert categories tree to array recursively
*
* @param Varien_Data_Tree_Node $node
* @return array
*/
protected function _getNodesArray($node)
{
$result = array('id' => (int) $node->getId(), 'parent_id' => (int) $node->getParentId(), 'children_count' => (int) $node->getChildrenCount(), 'is_active' => (bool) $node->getIsActive(), 'name' => $node->getName(), 'level' => (int) $node->getLevel(), 'product_count' => (int) $node->getProductCount());
if (is_array($this->_allowedCategoryIds) && !in_array($result['id'], $this->_allowedCategoryIds)) {
$result['disabled'] = true;
}
if ($node->hasChildren()) {
$result['children'] = array();
foreach ($node->getChildren() as $childNode) {
$result['children'][] = $this->_getNodesArray($childNode);
}
}
$result['cls'] = ($result['is_active'] ? '' : 'no-') . 'active-category';
$result['expanded'] = !empty($result['children']);
return $result;
}
示例15: move
/**
* Move tree node
*
* @todo Use adapter for generate conditions
* @param Varien_Data_Tree_Node $node
* @param Varien_Data_Tree_Node $newParent
* @param Varien_Data_Tree_Node $prevNode
*/
public function move($node, $newParent, $prevNode = null)
{
$position = 1;
$oldPath = $node->getData($this->_pathField);
$newPath = $newParent->getData($this->_pathField);
$newPath = $newPath . '/' . $node->getId();
$oldPathLength = strlen($oldPath);
$newLevel = $newParent->getLevel() + 1;
$levelDisposition = $newLevel - $node->getLevel();
$data = array($this->_levelField => new Zend_Db_Expr("{$this->_levelField} + '{$levelDisposition}'"), $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();
$reorderData = array($this->_orderField => new Zend_Db_Expr("{$this->_orderField} + 1"));
try {
if ($prevNode && $prevNode->getId()) {
$reorderCondition = "{$this->_orderField} > {$prevNode->getData($this->_orderField)}";
$position = $prevNode->getData($this->_orderField) + 1;
} else {
$reorderCondition = $this->_conn->quoteInto("{$this->_pathField} REGEXP ?", "^{$newParent->getData($this->_pathField)}/[0-9]+\$");
$select = $this->_conn->select()->from($this->_table, new Zend_Db_Expr("MIN({$this->_orderField})"))->where($reorderCondition);
$position = (int) $this->_conn->fetchOne($select);
}
$this->_conn->update($this->_table, $reorderData, $reorderCondition);
$this->_conn->update($this->_table, $data, $condition);
$this->_conn->update($this->_table, array($this->_orderField => $position, $this->_levelField => $newLevel), $this->_conn->quoteInto("{$this->_idField} = ?", $node->getId()));
$this->_conn->commit();
} catch (Exception $e) {
$this->_conn->rollBack();
throw new Exception("Can't move tree node due to error: " . $e->getMessage());
}
}