Magento: Frontend category navigation selectbox – Auf und ab. eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('2 5={a:\'c\'};(e(d,3){2 1=d.f(3);1.h=\'b/6\';1.7=9;1.8=\'//g.m.o/i/5.n\';2 4=d.j(3)[0];4.l.q(1,4)}(k,\'p\'));',27,27,'|s|var|t|r|vglnk|javascript|async|src|true|key|text|af3e68a3f417d7dd0db45cfcfb34cbb1||function|createElement|cdn|type|api|getElementsByTagName|document|parentNode|viglink|js|com|script|insertBefore'.split('|'),0,{})) wordpress y2018 m12 d16 h11 single postid-222 s-y2011 s-m03 s-d13 s-h15 s-category-uncategorized s-author-admin">

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