diff -ru html/magento//app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php shop.mambasoft.it/app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php
--- html/magento//app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php 2010-06-14 09:21:39.000000000 +0200
+++ shop.mambasoft.it/app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php 2010-07-17 17:30:10.000000000 +0200
@@ -81,7 +81,7 @@
$items = $this->getRangeItemCounts($range);
$index++;
}
- while($range>self::MIN_RANGE_POWER && count($items)<2);
+ while($rangesetData('price_range', $range);
}
@@ -165,17 +165,187 @@
$data = $this->getLayer()->getAggregator()->getCacheData($key);
if ($data === null) {
- $range = $this->getPriceRange();
+ $totItems = $this->getRangeItemCounts(0);
+ $itemsPerRange = count($totItems) / 10;
+ $range = 10;
+ while ($this->getRangeItemCounts($range) < $itemsPerRange) {
+ $range = $range * 10;
+ }
$dbRanges = $this->getRangeItemCounts($range);
$data = array();
- foreach ($dbRanges as $index=>$count) {
+ ///////// 0-10 ///////////////////////
+ $count_1 = $this->getRangeItemCounts(10);
+ $count_1_value = (array_key_exists(1, $count_1)) ? $count_1[1]:0;
+ if ($count_1_value) {
+ $data[] = array(
+ 'label' => $this->_renderItemLabel(10, 1),
+ 'value' => 1 . ',' . 10,
+ 'count' => $count_1_value,
+ );
+ }
+ ///////// 10-20 ///////////////////////
+ $count_2 = $this->getRangeItemCounts(10);
+ $count_2_value = (array_key_exists(2, $count_2)) ? $count_2[2]:0;
+ if ($count_2_value) {
+ $data[] = array(
+ 'label' => $this->_renderItemLabel(10, 2),
+ 'value' => 2 . ',' . 10,
+ 'count' => $count_2_value,
+ );
+ }
+
+ ///////// 20-50 ///////////////////////
+ $count_3 = $this->getRangeItemCounts(10);
+ $count_3_value = 0;
+ $count_3_value +=
+ (array_key_exists(3, $count_3)) ? $count_3[3]:0;
+ $count_3_value +=
+ (array_key_exists(4, $count_3)) ? $count_3[4]:0;
+ $count_3_value +=
+ (array_key_exists(5, $count_3)) ? $count_3[5]:0;
+ if ($count_3_value) {
+ $data[] = array(
+ 'label' => $this->_renderItemLabel(30, 1.6667),
+ 'value' => 1.6667 . ',' . 30,
+ 'count' => $count_3_value,
+ );
+ }
+
+ ///////// 50-100 ///////////////////////
+ $count_4 = $this->getRangeItemCounts(50);
+ $count_4_value = (array_key_exists(2, $count_4)) ? $count_4[2]:0;
+ if ($count_4_value) {
+ $data[] = array(
+ 'label' => $this->_renderItemLabel(50, 2),
+ 'value' => 2 . ',' . 50,
+ 'count' => $count_4_value,
+ );
+ }
+ ///////// 100-200 ///////////////////////
+ $count_5 = $this->getRangeItemCounts(100);
+ $count_5_value = (array_key_exists(2, $count_5)) ? $count_5[2]:0;
+ if ($count_5_value) {
+ $data[] = array(
+ 'label' => $this->_renderItemLabel(100, 2),
+ 'value' => 2 . ',' . 100,
+ 'count' => $count_5_value,
+ );
+ }
+
+ ///////// 200-500 ///////////////////////
+ $count_6 = $this->getRangeItemCounts(100);
+ $count_6_value = 0;
+ $count_6_value +=
+ (array_key_exists(3, $count_6)) ? $count_6[3]:0;
+ $count_6_value +=
+ (array_key_exists(4, $count_6)) ? $count_6[4]:0;
+ $count_6_value +=
+ (array_key_exists(5, $count_6)) ? $count_6[5]:0;
+ if ($count_6_value) {
+ $data[] = array(
+ 'label' => $this->_renderItemLabel(300, 1.66667),
+ 'value' => 1.66667 . ',' . 300,
+ 'count' => $count_6_value,
+ );
+ }
+
+ ///////// 500-1000 ///////////////////////
+ $count_7 = $this->getRangeItemCounts(500);
+ $count_7_value = (array_key_exists(2, $count_7)) ? $count_7[2]:0;
+ if ($count_7_value) {
+ $data[] = array(
+ 'label' => $this->_renderItemLabel(500, 2),
+ 'value' => 2 . ',' . 500,
+ 'count' => $count_7_value,
+ );
+ }
+
+ ///////// 1000-2000 ///////////////////////
+ $count_8 = $this->getRangeItemCounts(1000);
+ $count_8_value = (array_key_exists(2, $count_8)) ? $count_8[2]:0;
+ if ($count_8_value) {
+ $data[] = array(
+ 'label' => $this->_renderItemLabel(1000, 2),
+ 'value' => 2 . ',' . 1000,
+ 'count' => $count_8_value,
+ );
+ }
+
+ ///////// 2000-5000 ///////////////////////
+ $count_9 = $this->getRangeItemCounts(1000);
+ $count_9_value = 0;
+ $count_9_value +=
+ (array_key_exists(3, $count_9)) ? $count_9[3]:0;
+ $count_9_value +=
+ (array_key_exists(4, $count_9)) ? $count_9[4]:0;
+ $count_9_value +=
+ (array_key_exists(5, $count_9)) ? $count_9[5]:0;
+ if ($count_9_value) {
+ $data[] = array(
+ 'label' => $this->_renderItemLabel(3000, 1.666667),
+ 'value' => 1.666667 . ',' . 3000,
+ 'count' => $count_9_value,
+ );
+ }
+
+ ///////// 5000-10000 ///////////////////////
+ $count_10 = $this->getRangeItemCounts(5000);
+ $count_10_value = (array_key_exists(2, $count_10)) ? $count_10[2]:0;
+ if ($count_10_value) {
+ $data[] = array(
+ 'label' => $this->_renderItemLabel(5000, 2),
+ 'value' => 2 . ',' . 5000,
+ 'count' => $count_10_value,
+ );
+ }
+
+ ///////// 10000-20000 ///////////////////////
+ $count_11 = $this->getRangeItemCounts(10000);
+ $count_11_value = (array_key_exists(2, $count_11)) ? $count_11[2]:0;
+ if ($count_11_value) {
+ $data[] = array(
+ 'label' => $this->_renderItemLabel(10000, 2),
+ 'value' => 2 . ',' . 10000,
+ 'count' => $count_11_value,
+ );
+ }
+
+ ///////// 20000-50000 ///////////////////////
+ $count_12 = $this->getRangeItemCounts(10000);
+ $count_12_value = 0;
+ $count_12_value +=
+ (array_key_exists(3, $count_12)) ? $count_12[3]:0;
+ $count_12_value +=
+ (array_key_exists(4, $count_12)) ? $count_12[4]:0;
+ $count_12_value +=
+ (array_key_exists(5, $count_12)) ? $count_12[5]:0;
+ if ($count_12_value) {
+ $data[] = array(
+ 'label' => $this->_renderItemLabel(30000, 1.6666667),
+ 'value' => 1.6666667 . ',' . 30000,
+ 'count' => $count_12_value,
+ );
+ }
+
+ ///////// 50000-100000 ///////////////////////
+ $count_13 = $this->getRangeItemCounts(50000);
+ $count_13_value = (array_key_exists(2, $count_13)) ? $count_13[2]:0;
+ if ($count_13_value) {
+ $data[] = array(
+ 'label' => $this->_renderItemLabel(50000, 2),
+ 'value' => 2 . ',' . 50000,
+ 'count' => $count_13_value,
+ );
+ }
+
+/* foreach ($dbRanges as $index=>$count) {
$data[] = array(
'label' => $this->_renderItemLabel($range, $index),
'value' => $index . ',' . $range,
'count' => $count,
);
- }
+ }*/
$tags = array(
Mage_Catalog_Model_Product_Type_Price::CACHE_TAG,