我正在尝试在magento 1.6首页上显示一个特定父类别的子类别(在这种情况下是ID为23的类别),但代码始终显示所有现有父类别和子类别。
有人能指出我正确的方向吗?
<?php $children=Mage::getModel('catalog/category')->getCollection(23)->load(); ?>
<?php $i=0; foreach ($children as $child): ?>
<?php if ($i++%3==0): ?>
<?php endif ?>
<?php $subCategory = Mage::getModel('catalog/category')->load($child->getId()); ?>
<a href="<?php echo $child->getURL() ?>
" title="<?php echo $this->htmlEscape($child->getName()) ?>"> <?php echo $this->htmlEscape($child->getName()) ?></a> <?php echo $subCategory->getDescription() ?>
<?php if ($i%3==0 && $i!=$_collectionSize): ?>
<?php endif ?>
<?php endforeach ?>
<?php for($i;$i%3!=0;$i++): ?>
<?php endfor ?>
<?php if ($i%3==0): ?>
<?php endif ?>
由于
答案 0 :(得分:0)
请改为:
Mage::getModel('catalog/category')->load('23')->getChildrenCategories();
并迭代结果。
这就是我发现它的方式:
$object = Mage::getModel('catalog/category');
print_r(get_class_methods($object));
print_r($object->load('23')->getChildrenCategories()->toArray());