Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在magento中筛选目录/类别_Php_Magento - Fatal编程技术网

Php 如何在magento中筛选目录/类别

Php 如何在magento中筛选目录/类别,php,magento,Php,Magento,我正在尝试获取仅限于搜索查询的类别列表$searchstring 这是一个我必须过滤的产品 $_productCollection = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToSort('created_at', 'DESC') ->addAttributeToSe

我正在尝试获取仅限于搜索查询的类别列表$searchstring 这是一个我必须过滤的产品

$_productCollection = Mage::getModel('catalog/product')
                    ->getCollection()
                    ->addAttributeToSort('created_at', 'DESC')
                    ->addAttributeToSelect('*')
                    ->setPageSize(20)
                    ->addAttributeToFilter('name', array('like' => '%'.$searchstring.'%'))<---this line
                    ->load();

谢谢

Malcolm-我删除了我的问题,因为我认为我完全误解了你想要什么。是否要将搜索字符串筛选器应用于已获得的类别集合?是,确实可以这样做吗?
$_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();

            }
        }
    }
}