我正在尝试获取仅限于搜索查询的类别列表 $ searchstring 这是我必须过滤产品
$_productCollection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSort('created_at', 'DESC')
->addAttributeToSelect('*')
->setPageSize(20)
->addAttributeToFilter('name', array('like' => '%'.$searchstring.'%'))<---this line
->load();
但是我需要过滤类别。如何编辑以下代码来过滤类似上面的类别
$_helper = Mage::helper('catalog/category');
$_categories = $_helper->getStoreCategories();
if (count($_categories) > 0){
foreach($_categories as $_category){
$_category = Mage::getModel('catalog/category')->load($_category->getId());
$_subcategories = $_category->getChildrenCategories();
if($_category->getImageUrl()!= ""){$categoryimage = $_category->getImageUrl();}else{$categoryimage = "http://www.flintout.com/img/roughrock.jpg";}
echo $categoryimage;
echo $_category->getName();
echo $_category->getDescription();
if (count($_subcategories) > 0){
foreach($_subcategories as $_subcategory){
if($_subcategory->getImageUrl()!= ""){$subcategoryimage = $_subcategory->getImageUrl();}else{$subcategoryimage = "http://www.flintout.com/img/roughrock.jpg";}
echo $subcategoryimage;
echo $_subcategory->getName();
echo $_subcategory->getDescription();
}
}
}
}
谢谢