Magento: Frontend category navigation selectbox

I was looking for some way of adding a selectbox in the navigation so that one could pick a category and then get directed to the page with all products in that category. After much looking I found this page, that did sort of what I wanted. Customizing I got the following code for the top block in Magento.

<div class="header-nav-container">
  <div class="header-nav">
    <select class="browser_box" name="browser" onchange="location = this.options[this.selectedIndex].value;">
      <option>Please select a category...</option>
<?php
  $obj = new Mage_Catalog_Block_Navigation();
  $store_cats = $obj->getStoreCategories();
  $current_cat = $obj->getCurrentCategory();
  $current_cat = (is_object($current_cat) ? $current_cat->getName() : '');
 
  foreach ($store_cats as $cat) {
	  echo '<option value="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</option>";
  }
?>
    </select>
  </div>
</div>

Post a Comment

Your email is never shared. Required fields are marked *

*
*

Auf und ab. (RSS) + Sator-ii theme by Felipe LavĂ­n