I’m new to Magento. I have a 'select-box' that list all the main 'categories-name'. How to get 'Category-name' in 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With