`
kirenenko04
  • 浏览: 151052 次
  • 性别: Icon_minigender_2
  • 来自: 上海
社区版块
存档分类
最新评论

Check the category is a child of another category or not

 
阅读更多
	public function isUnderApparel($cate_id, $parent_id) {
		$collection = Mage::getModel('catalog/category')->getCollection()
		->addAttributeToFilter('entity_id', array('eq' => $parent_id)); // 服装分类的ID
		foreach ($collection as $c) {
			$parent = $c;
			break;
		}
		$sub_cateids = array();
		$sub_cateids = $this->retrieveAllChilds($parent->getId());
		return in_array($cate_id, $sub_cateids);
	}

	public function retrieveAllChilds($id = null) {
		$category = Mage::getModel('catalog/category')->load($id);
		return $category->getResource()->getChildren($category, true);
	}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics