Have you already tried the Improved Navigation plugin? It does exactly what you are asking for. We are open for customization if you like to modify some aspects of the solution.
where CUSTOM NUMBER should be the extracted root of the price-step you want to have.
Example:
By default the value is 10 - means the steps are in 100 USD (10 is the extracted root of 100)
If you want to have steps of 5 then you should enter: 2.236067977499789 (which is the extracted root of 5)
If you want to have steps of 6,25 then you should enter: 2,5
If you want to have steps of 10 you should enter: 3.1622776601
I didn`t test how many digits after the decimal-point are needed - check it our yourselves This is an absolute idiotic solution - but it works
I’m sorry again. I could fix the price range as I want to show, but some products are in a wrong price range. I looked the code over and over but I have no idea how to fix it any more.
This wide dynamic price change with this static navigation on the site does not exist and the price levels. Also, this is not in the currency of anything except the simple products.
[ this solution is for an old version of magento 1.3 i believe i cant remember, ill update to implement the same in a newer version but the basic difference is that instead $items[] = $this->_createItem would be something like $data[] = array(.... but ive to check it ]
deggertsen have the perfect solution. The only drawback is that is hard to calculate the counts every time you rearrange the price rankss. so i made an algorithm programmed for the analitic solution to generate ranks.
instead to do what deggertsen does, you could just do this:
here is the methods that suport to do something like that and you just have to add to Mage_Catalog_Model_Layer_Filter_Price, and as you can see in the line
if(!$rank_count)continue;
when a rank does not contains a result it will be not showed:
private function amps_to_ranks($amps, $start_price=0){ $ranks = array(); foreach($amps as $amp) $ranks[] = array($start_price, $start_price = $start_price+$amp); return($ranks); } private function boundaryes_to_ranks($boundaryes){ $ranks = array(); $first = array_shift($boundaryes); foreach($boundaryes as $boundary){ $ranks[] = array($first, $first = $boundary); } return($ranks); } private function find_div($min, $div, $fixed_jumps=null){ $orig_div = $div; $prime_numbers = array(2,3,5,7,11,13,17,23);//here you could add a larger amount of prime numbers, depends on how complex will be your ranks, this should be fine while(($min%$div)!==0){ $current_jump = isset($fixed_jumps)&&count;($fixed_jumps)?array_pop($fixed_jumps):0; foreach($prime_numbers as $idx=>$prime_number) if($current_jump<=$idx&&!($div%$prime_number)){ $div = $div / $prime_number; break; } if($div===$orig_div) break; } return($div); } private function best_div($min, $div){ $jumps = array(0,1,2,3,4); $arr_jumps = array(); foreach($jumps as $i) foreach($jumps as $j) if($i || $j) $arr_jumps[] = array($i, $j); $orig_div = $div; $found_divs = array(); $new_div = $this->find_div($min, $div); if($orig_div!=$new_div) $found_divs[] = $new_div; foreach($arr_jumps as $jumps){ $new_div = $this->find_div($min, $div, $jumps); if($new_div!=$orig_div) $found_divs[$jumps[0].','.$jumps[1]] = $new_div; } $best_div = $orig_div; if($found_divs) $best_div = max($found_divs); return($best_div); } private function getItemsByRanks($ranks){ //var_dump($ranks);die(); $interval_counts = array(); $items = array(); foreach($ranks as $rank){ $min = $rank[0]; $max = $rank[1]; $amp = $max - $min; $div = $amp; $div = $this->best_div($min, $div); if($min%$div)//wont be able to find the count without a divisor so stop here continue; if(!isset($interval_counts[$div])){ $interval_counts[$div] = $this->getRankItemCounts($div);//cache results } $rank_count = 0; $istart = $min / $div; $iend = $istart + $amp / $div; for($i=$istart; $i<$iend; $i++){ if(isset($interval_counts[$div][$i+1])) $rank_count += $interval_counts[$div][$i+1]; } if(!$rank_count)continue; $idx = $max / $amp;
Hi, I have price range from 0 - 10000 can anyone help me??
I try to use code given by greg in first page then I got some error.
Need help !!!
I am using magento 1.5.
while (ceil($maxPrice / $range) > 25) {
$range *= 10;
}
*/<< command $range = 50; //custom range of $0 - $50, $50 - $100, $50 - $100, $100 - $150 and so forth, you can set any number
$this->setData(’price_range’, $range);
}
1. Go to System > Configuration > Catalog (under Catalog) > Layered Navigation
2. Change the Price Navigation Step Calculation dropdown from Automatic to Manual
3. Enter the amount you want it to be (e.g. - 50) into the Default Price Navigation Step input box
4. Save