모든 카테고리 목록을 자동 검색 필드에 표시하고 싶습니다. 그래서는 같은 쿼리 코드가 -magento와 같은 검색어로 카테고리 컬렉션 가져 오기
function res($cur_category){
$children_categories = Mage::getModel('catalog/category')->getCategories($cur_category->getId());
$children_categories->addAttributeToFilter('name', array('like' => '%a%'));
foreach($children_categories as $child){
$name = $child->getName();
$option.='<li onClick="fill(\''.addslashes($child->getName()).'\');">' .$child->getName(). "</li>";
$option.=res($child);
}
unset($children_categories);
return $option;
}
function GetTree(){
$rootcatId= Mage::app()->getStore()->getRootCategoryId();
$categories = Mage::getModel('catalog/category')->getCategories($rootcatId);
$categories->addAttributeToFilter('name', array('like' => '%a%'));
foreach($categories as $category)
{
$option.='<li onClick="fill(\''.addslashes($category->getName()).'\');">'.$category->getName()."</li>";
if($category->hasChildren()){
$option.= res($category);
}
}
unset($categories);
return $option;
}
echo $select = '<ul>'.GetTree().'</ul>';
을하지만 쿼리처럼 제대로 벌금과 쇼 카테고리 목록을 노력없이이 코드는 같은 쿼리 작동하지 않습니다. 제발 같이 쿼리를 제공하십시오.