| 
	因magento业务需要,Category增加了一个属性叫promo_name,进入Category列表页时希望将其显示出来,这里的情况具体分两种:  
	I. load方法访问自定义属性  
	Php代码  收藏代码 
	$c = Mage::getModel('catalog/category');   
	echo $c->getPromoName();   
	这个是最自然的用法,麻烦的是下面的情况:  
	II. 首先得到了树状的Category(不是平面的), 看下面代码示例  
	Php代码  收藏代码 
	public function getCategoryNodes($parentId = null,  $sorted=false, $asCollection=false, $toLoad=true) {   
	   $config = Mage::getModel('catalogue/joyconfig');   
	   if(emptyempty($parentId)) {   
	      $parentId = $config->getRootBrandId();   
	   }   
	   $category = Mage::getModel('catalog/category');   
	   /* @var $category Mage_Catalog_Model_Category */   
	   if (!$category->checkId($parentId)) {   
	      if ($asCollection) {   
	         return new Varien_Data_Collection();   
	      }   
	      return array();   
	   }   
	   $recursionLevel = max(0, 0);   
	   $tree = $category->getTreeModel();   
	   $nodes = $tree->loadNode($parentId)   
	      ->loadChildren($recursionLevel)   
	      ->getChildren();   
	   $tree->addCollectionData(null, $sorted, $parentId, $toLoad, true);   
	   if ($asCollection) {   
	      return $tree->getCollection();   
	   } else {   
	      return $nodes;   
	   }   
	}   
	其功能是:给定一个category_id,返回该id下所有子分类以树状结构返回,为了让返回的每个节点(Category Node)包含该定制属性, 在代码  
	Php代码  收藏代码 
	$tree->addCollectionData(null, $sorted, $parentId, $toLoad, true);   
	前增加如下的行:  
	Php代码  收藏代码 
	$tree->getCollection($sorted)->addAttributeToSelect('promot_name');   | 



 ecshop精仿京东商城模板2
							人气:1362
							ecshop精仿京东商城模板2
							人气:1362
						 ecshop仿蘑菇街2016最新模板
							人气:711
							ecshop仿蘑菇街2016最新模板
							人气:711
						 仿yoybuy淘宝海外英文代购
							人气:3079
							仿yoybuy淘宝海外英文代购
							人气:3079
						 ecshop仿唯棉模板
							人气:996
							ecshop仿唯棉模板
							人气:996
						 shopex也买酒模板
							人气:630
							shopex也买酒模板
							人气:630
						 shopex仿普派商城模板
							人气:757
							shopex仿普派商城模板
							人气:757