Magento-列出特定父类别的子类别作为链接 [英] Magento - list sub-categories of a specific parent category as links

查看:51
本文介绍了Magento-列出特定父类别的子类别作为链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是php的初学者,并且坚持尝试仅将一个父类别的子类别称为链接

I am a beginner to php and am stuck on trying to call out sub-categories of just one parent category as links

我明白了,它显示了getName,但是getUrl()根本没有返回任何URL....

I got to this and it’s bringing up the getName but the getUrl() isn’t returning any URL at all....

<?php
      $children = Mage::getModel('catalog/category')->getCategories(3);
      foreach ($children as $category):
            echo '<li><a href="' . $category->getUrl() . '">' . $category->getName() . '</a></li>';
      endforeach;
?>

输出代码仅为<li><a href="">name of sub-cat</a></li>

有人有什么想法吗?请?

Anybody have any ideas? Please?

谢谢, 凯拉

推荐答案

请尝试使用此代码,我认为您已完成此代码,但这对正在搜索此代码的人很有帮助

Please try this code I think you did this code but this is very helpful for someone who is searching this code

<?php
    $children = Mage::getModel('catalog/category')->getCategories(3);
    foreach ($children as $category):
        $category = Mage::getModel('catalog/category')->load($category->getId());
        echo '<li><a href="' . $category->getUrl() . '">' . $category->getName() . '</a></li>';
    endforeach;
?>

这篇关于Magento-列出特定父类别的子类别作为链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆