gpt4 book ai didi

php - Magento getUrl 不适用于目录/类别对象?

转载 作者:可可西里 更新时间:2023-10-31 23:02:49 26 4
gpt4 key购买 nike

我已经能够实例化一个类别对象来检索它的名称,但是当我使用 getUrl 方法时,它没有返回指向类别列表页面的 URL 或任何东西

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

上面的代码产生了

的 HTML 输出
<li><a href="">name of sub-cat</a></li>`

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

最佳答案

替换

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

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

关于php - Magento getUrl 不适用于目录/类别对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5890932/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com