Pages

Tuesday, June 25, 2013

Fetch Subcategory of a category in magento in select box dropdown

<select name="" style="width:220px;" onchange="location.href=this.value">
  <?php $children  = Mage::getModel('catalog/category')->getCategories(YOUR_CAT_ID); ?>

 <?php foreach ($children as $category) {  $i++;
 $cat = Mage::getModel('catalog/category')->load($category->getID()); ?>
  <option value="<?php echo $cat->geturl(); ?>"  <? if(Mage::registry('current_category')->getId()==$category->getID()) echo 'selected';?>><?php echo $category->getName(); ?></option>
 <?php } ?>

 </select>

No comments:

Post a Comment