php 从主类别中获取Magento子类别列表
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 从主类别中获取Magento子类别列表相关的知识,希望对你有一定的参考价值。
https://magento.stackexchange.com/questions/95099/how-get-all-subcategories-of-specific-category
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $categoryId = 3;?>
<?php $category = Mage::getModel('catalog/category')->load($categoryId) ?>
<?php $_categories = $category->getChildrenCategories() ?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>"><?php echo $_category->getName() ?></a>
<?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ; ?>
<!-- delete these subcategories if you only need the parent of subcategories of the main category -->
<?php if($_category->hasChildren()):?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<ul id="subcategory">
<?php foreach($_subcategories as $_subcategory): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>"><?php echo $_subcategory->getName() ?></a>
<?php $_category2 = Mage::getModel('catalog/category')->load($_subcategory->getId()) ?>
<?php if($_category2->hasChildren()):?>
<?php $_subcategories2 = $_category2->getChildrenCategories() ?>
<ul>
<?php foreach($_subcategories2 as $_subcategory2): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_subcategory2) ?>"><?php echo $_subcategory2->getName() ?></a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<!-- SUBCATEGORIES -->
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
以上是关于php 从主类别中获取Magento子类别列表的主要内容,如果未能解决你的问题,请参考以下文章
Magento 中的子类别列表
所有产品(类别和子类别产品)都计入 magento 中的类别列表页面
在Magento中获取子类别
Magento 获取子类别/类别集合处理。编程效率
PHP 获取Magento类别的URL
获取magento类别view.phtml的特定属性