문제

when i start filtering the priceslider from the min price in which in my case is $0 the slider works fine but when i start filtering from max value (keeping the min value to 0 ) nothing changes but when adjust /increase the filter to a non zero value the max value limit is applied, even if i set some static min value like 1$ or 2$ slider works fine but not with zero value

this is my slider code (relevent code)

$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
        $currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
        $rate = round(Mage::helper('directory')->currencyConvert(1.0000, $baseCurrencyCode, $currentCurrencyCode),2);
        if($this->_currMaxPrice > 0){$Curmax = $this->_currMaxPrice;} else{$Curmax = $this->getMaxRangePrice; }
        if($this->_currMinPrice > 0){$Curmin = $this->_currMinPrice;} else{$Curmin = $this->getMinRangePrice;}
        $minRange = $this->getMinRangePrice();
        $maxRange = $this->getMaxRangePrice();
        $minRange = $minRange * $rate;
        $maxRange = $maxRange * $rate;
        if(!isset($_GET['rate'])) {
            $Curmax = $Curmax * $rate;
            $Curmin = $Curmin * $rate;}



<div id="slider-range"></div>

script file /slider

$jq( "#slider-range" ).slider({
    range: true,
    min: min,
    max: max,
    values: [ currentMinPrice, currentMaxPrice ],
    slide: function( event, ui ) {
        $jq( "#amount" ).val( currencies + ui.values[ 0 ] + " - "+ currencies + ui.values[ 1 ] );
        $jq('input[name="first_price"]').val(ui.values[0]);
        $jq('input[name="last_price"]').val(ui.values[1]);
    },
    stop: function( event, ui ) {
        var first =   ui.values[0];
        var  last =  ui.values[1];
         var baseUrl = '<?php echo $baseUrl; ?>'+'?rate='+rate+'&first='+first+'&last='+last+params;
             ajaxFilter(baseUrl);

    }
});

$jq( "#amount" ).val( currencies + $jq( "#slider-range" ).slider( "values", 0 ) +
    " - "+currencies + $jq( "#slider-range" ).slider( "values", 1 ) );
$jq('input[name="first_price"]').val($jq( "#slider-range" ).slider( "values", 0 ));
$jq('input[name="last_price"]').val($jq( "#slider-range" ).slider( "values", 1 ));   
도움이 되었습니까?

해결책

Your problem is of course in the core code, and I just learned how the price slider works.

Your problem with the 0 lies here:

\Mage_Catalog_Model_Layer_Filter_Price::_validateFilter
protected function _validateFilter($filter)
{
    $filter = explode('-', $filter);
    if (count($filter) != 2) {
        return false;
    }
    foreach ($filter as $v) {
        if (($v !== '' && $v !== '0' && (float)$v <= 0) || is_infinite((float)$v)) {
            return false;
        }
    }

    return $filter;
}

This validation checks whether ALL filters are > 0, and if this is not the case the filter is ignored (I guess, no idea what happens if this method returns false, but makes sense), so you should have at least 0.01$ or 1$ as bottom limit.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top