Magento getUrl无法与目录/类别对象一起使用? [英] Magento getUrl not working with catalog/category object?

查看:88
本文介绍了Magento getUrl无法与目录/类别对象一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经能够实例化类别对象以检索其名称,但是当我使用getUrl方法时,它并没有将URL返回到类别列表页面,或者根本没有返回

I've been able to instantiate a category object to retrieve its name, but when I use the getUrl method it isn't returning a URL to the category listing page, or anything 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>`

有人知道如何从catalog/category对象获取类别页面的URL吗?

Does anyone know how I can get the URL for a category page from a catalog/category object?

推荐答案

替换

$children = Mage::getModel('catalog/category')->getCategories(3);

使用

$children = Mage::getModel('catalog/category')->load(3)->getChildrenCategories();

这篇关于Magento getUrl无法与目录/类别对象一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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