Php 在侧边栏上显示单个Magento类别
如何在侧边栏上显示单个类别树Php 在侧边栏上显示单个Magento类别,php,model-view-controller,magento,categories,Php,Model View Controller,Magento,Categories,如何在侧边栏上显示单个类别树 不是产品,只是类别树。我一直在使用它来做类似的事情。为您自己做这件事的正式方法是使用模块创建者创建一个模块(搜索Magento Connect以获取此链接),然后: 使用以下代码创建新的phtml文件: $storeCategories = $this->getCats('my-category-url-key'); foreach ($storeCategories as $category): echo '<l
不是产品,只是类别树。我一直在使用它来做类似的事情。为您自己做这件事的正式方法是使用模块创建者创建一个模块(搜索Magento Connect以获取此链接),然后: 使用以下代码创建新的phtml文件:
$storeCategories = $this->getCats('my-category-url-key');
foreach ($storeCategories as $category):
echo '<li><a href="' . $category->getUrl() . '">' . $category->getName() . '</a></li>';
endforeach;
public function getCats($catName)
{
$parent = Mage::getResourceModel('catalog/category_collection')
->addAttributeToSelect('entity_id')
->addAttributeToFilter('url_key', $catName)
->getFirstItem();
return $storeCategories = Mage::getModel('catalog/category')
->getCategories( $parent->getId(), $recursionLevel=1, $sorted=false, $asCollection=true, $toLoad=false);
}
然后,只需将以下节点插入app\design\frontend\yourtheme\layout\yourmodule.xml
layout文件:
<reference name="left">
<block type="yourmodule/singlecat" name="singlecat" template="path/yourfilename.phtml" />
</reference>
交叉你的手指,向你选择的神祈祷,Magento可能会对你的密码微笑:)