Display subcategories and its subcategories in dropdown menu
-
09-12-2020 - |
Question
I am making something like mysmartprice menu in magento, can anybody point me to the resource or search term. I have UI read with me, i just need the correct loop or function to begin. I am familiar with magento theme making, i have made some themes for ecommerce website also, but for this sub-category and its sub-category i am bit confuse.
Any Help would be appreciated.
Solution
Here is the code to display all the categories in a select dropdown, you may have to make some modifications depending on what you need:
<select id="category" name="category">
<?php
$rootCat = Mage::app()->getStore()->getRootCategoryId();
$categories = explode(',',Mage::getModel('catalog/category')->load($rootCat)->getChildren());
foreach($categories as $cat){
$category = Mage::getModel('catalog/category')->load($cat);
?>
<option value="<?php echo $category->getId();?>"><?php echo $category->getName();?></option>
<?php } ?>
</select>
OTHER TIPS
"Thanks for the info. Great Read ! Found https://saverupaya.com/"" target=""_blank""> this site that compares the prices of latest gadgets, home accessories, fitness accessories and many more across markets at https://saverupaya.com/"" target=""_blank""> Save Rupaya and you also will be notified about availability of products with price drops.
"