4

How to make a custom attribute in magento to show as range in layered navigation like price any ideas please help

1
  • guys any help on this please Commented Jul 7, 2014 at 7:23

1 Answer 1

8

So in principle what you will need to do is create your own model for the filter and then in this model create a function _getItemsData. This function will create all the filter items that need to be shown, in your case the different ranges. Each item should be in the following format.

$data[] = array( 'label' => 'String To show for the filter', 'value' => $fromValue . '-' . $toValue, 'count' => 'How many items are in this range', ); 

When you create a filter block you can attach a model for calulating it's data via $this->_filterModelName = 'your/layer_filter_model';

How to add new filters I am not completely sure but once that has been sorted the key is getting the data items. You can look into how the price filter works and mirror this.

2
  • 1
    Thanks for your suggestion david.What i did is select type as price when creating new attribute. That worked for me a bit. Commented Mar 18, 2015 at 20:53
  • 3
    @Magesavvy welcome back to the site! You should make your solution an answer if possible so others can more accurately see what you've done :D Commented Mar 19, 2015 at 12:39

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.