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);
	}

 

你可能感兴趣的:(check)