如何优化图像加载所有类别
现在,我有两个嵌套的foreach可以遍历所有类别,而且速度非常慢(本地服务器上为3-4秒)。我认为问题是我使用-> LOAD()来获取子类别的图像路径。还有其他方法吗?还是我应该重新设计整个导航ui?有什么建议吗? $categories = Mage::getSingleton('catalog/category') ->getCollection() ->addAttributeToSelect('id') ->addAttributeToSelect('name') ->addAttributeToSelect('url_key') ->addAttributeToSelect('url') ->addAttributeToFilter('level',2) ->addIsActiveFilter() ->addAttributeToSort('position'); foreach ($categories as $category): $id = $category->getId(); $children = $category->getChildrenCategories(); $name = $category->getName(); $url_path = $category->getUrl(); foreach ($children as $child): $childId = $child->getId(); $thisChild = Mage::getSingleton('catalog/category')->load($childId); $name = $thisChild->getName(); $url_key = $thisChild->getUrlKey(); $url_path = $child->getUrl(); $img = …