我是 Magento 新手。 我有一个“选择框”,其中列出了所有主要的“类别名称”。 如何在 Magento 中获取“类别名称”?
最佳答案
<select>
<?php
$category = Mage::getModel('catalog/category');
$tree = $category->getTreeModel();
$tree->load();
$ids = $tree->getCollection()->getAllIds();
if ($ids)
{
foreach ($ids as $id)
{
$cat = Mage::getModel('catalog/category');
$cat->load($id);
if($cat->getLevel()==1 && $cat->getIsActive()==1)
{
echo "<option>";
echo $cat->getName();
echo "</option>";
}
}
}
?>
</select>
关于php - 如何在 Magento 中获取类别名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16955770/