Skip to content

Commit cb1a95f

Browse files
committed
Resolves smartstore#1322 Price facets can end in infinite loop
1 parent 8eff9d6 commit cb1a95f

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/Libraries/SmartStore.Services/Search/Extensions/FacetUtility.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace SmartStore.Services.Search.Extensions
88
{
99
public static class FacetUtility
1010
{
11+
private const double MAX_PRICE = 1000000000;
12+
1113
private static int[,] _priceThresholds = new int[,]
1214
{
1315
{ 10, 5 },
@@ -39,23 +41,23 @@ public static double GetNextPrice(double price)
3941
return price + _priceThresholds[i, 1];
4042
}
4143

42-
return 1000000000;
44+
return MAX_PRICE;
4345
}
4446

4547
public static double MakePriceEven(double price)
4648
{
4749
if (price == 0.0)
4850
return GetNextPrice(0.0);
4951

50-
// get previous threshold for price
52+
// Get previous threshold for price.
5153
var result = 0.0;
5254
for (var i = 1; i <= _priceThresholds.GetUpperBound(0) && result == 0.0; ++i)
5355
{
5456
if (price < _priceThresholds[i, 0])
5557
result = _priceThresholds[i - 1, 0];
5658
}
5759

58-
while (result < price)
60+
while (result < price && result < MAX_PRICE)
5961
{
6062
result = GetNextPrice(result);
6163
}

0 commit comments

Comments
 (0)