Magento – overriding Magento toolbar.phtml file

phtmlsearchtoolbar

I am editing the file \app\design\frontend\base\default\template\catalog\product\list\toolbar.phtml through my own module. I want to specify the available categories on the current list.

Example: I search for "shirt" and the products that contains "shirt" is in 2 categories: summer and winter.

The idea is that the user can filter by (not order by) one of the two categories available.
I searched this function:

<?php foreach ($this->getAvailableLimit() as  $_key=>$_limit): ?> 

I found out that it only works with specific attributes of product and only for "order by", but what about the categories? and if I want to "filter by"?

Is that possible? Any ideas?

Thanks!

I response to myself:

I do it!

On the one hand I copied the file toolbar.php to override it (and add my personalized functions) and secondly the List.php file to edit the collection list and add my category_id filter. Finally I edited my toolbar.phtml file to add the dropdown list with available categories and get the categoryId param to keep selected the category in the dropdown.

Best Answer

You can make categories filterable in the layered navigation. In the admin, if you set the category setting "Is Anchor?", that category will become a filterable attribute. This way you don't have customize it in the toolbar filters.

Related Topic