Revision: 43871
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 1, 2011 18:30 by rahijain
Initial Code
$products_count = $result->RecordCount();
$productArray = $result->GetArray();
$productSum = 0;
foreach($productArray as $price){
$productSum = $productSum + intval($price['products_price']);
}
$median = intval($productSum/$products_count);
if ($median > 100){
$median = intval($median/100);
$median = $median*100;
}
$second_price = $median;
$lower_count = 0;
$lower_median_sum =0;
foreach ($productArray as $price){
if ($price['products_price'] < $median){
$lower_count++;
$lower_median_sum = $price['products_price'] + $lower_median_sum;
}
}
if ($lower_count > 1){
$first_price = intval($lower_median_sum/$lower_count);
}
$upper_count = 0;
$upper_median_sum = 0;
foreach ($productArray as $price){
if ($price['products_price'] > $median){
$upper_count++;
$upper_median_sum = $price['products_price'] + $upper_median_sum;
}
}
if ($upper_count > 1){
$third_price = intval($upper_median_sum/$upper_count);
}
if ($first_price > 100){
$first_price = intval($first_price/100);
$first_price = $first_price*100;
}
if ($third_price > 100){
$third_price = intval($third_price/100);
$third_price = $third_price*100;
}
//return self::getPriceRangeArray($row['totalProduct'],$row['sum'],$productStatus,$brandID,$categoryIds);
$priceRangeArray = array();
$i=0;
if($products_count > 1 ){
if (isset($first_price)){
if(self::checkPriceRange(0,$first_price,$productStatus,$brandID,$categoryIds)>0) {
$priceRangeArray[$i]['range'] = '0-'.$first_price;
$priceRangeArray[$i]['label'] = 'Below Rs.'.$first_price;
$i++;
}
if(self::checkPriceRange($first_price,$second_price,$productStatus,$brandID,$categoryIds)>0) {
$priceRangeArray[$i]['range'] = $first_price.'-'.$second_price;
$priceRangeArray[$i]['label'] = 'Rs.'.$first_price .' - Rs.'.$second_price;
$i++;
}
} else {
if(self::checkPriceRange(0,$second_price,$productStatus,$brandID,$categoryIds)>0) {
$priceRangeArray[$i]['range'] = '0-'.$second_price;
$priceRangeArray[$i]['label'] = 'Below Rs.'.$second_price;
$i++;
}
}
if (isset($third_price)){
if(self::checkPriceRange($second_price,$third_price,$productStatus,$brandID,$categoryIds)>0) {
$priceRangeArray[$i]['range'] = $second_price.'-'.$third_price;
$priceRangeArray[$i]['label'] = 'Rs.'.$second_price .' - Rs.'.$third_price;
$i++;
}
if(self::checkPriceRange($third_price,999999,$productStatus,$brandID,$categoryIds)>0) {
$priceRangeArray[$i]['range'] = $third_price.'-99999999';
$priceRangeArray[$i]['label'] = 'Rs.'.$third_price.' Above';
$i++;
}
} else {
if(self::checkPriceRange($second_price,999999,$productStatus,$brandID,$categoryIds)>0) {
$priceRangeArray[$i]['range'] = $second_price.'-99999999';
$priceRangeArray[$i]['label'] = 'Rs.'.$second_price.' Above';
$i++;
}
}
Initial URL
Initial Description
Initial Title
Price Range for products list
Initial Tags
php
Initial Language
PHP