Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter Price ranges! How can i do it? #46

Open
NunoBentes opened this issue Apr 9, 2013 · 0 comments
Open

Filter Price ranges! How can i do it? #46

NunoBentes opened this issue Apr 9, 2013 · 0 comments

Comments

@NunoBentes
Copy link

Hi guys

I´m building a filter form with Advsearch plugin, but now i´m having some troubles in filtering prices.
How can i put this working? I tried, but it´s not working!! This is not an issue for sure, it´s something that i´m not doing well and because of that isn´t working!! :)

Many thanks in advance,
Legues

The form part is this one:

<select name="pricerange" class="selecter"> <option selected="selected" value="all">Select a price range</option> <option value="all">Any</option> <option>0-500,000€</option> <option>500,000-1,000,000€</option> <option>1,000,000-1,500,000€</option> <option>1,500,000-2,000,000€</option> <option>>2,000,000€</option> </select>

Then i tried a queryhook like this one:

 * AdvSearch
 *
 * Copyright 2012 by Coroico <[email protected]>
 *
 * QueryHook for Faceted search demo 1
 *
 */

$andConditions = array(
    'tv.property-type:=' => 'type:request:all',
    'tv.property-number-bedrooms:=' => 'bedrooms:request:all',
    'tv.property-location:=' => 'location:request:all'
);

$requests = array();

// price
$tag = 'pricerange';
$pricerange = strip_tags($_GET[$tag]);
if (!empty($pricerange)) {
    $vpricerange = substr($pricerange,0,-1); // to clear the money unit
    if ($vpricerange == '>2,000,000') {
        $andConditions['tv.property-price:>'] = '2,000,000:numfield';
    }
    else {
        list($pinf,$psup) = explode('-',$vpricerange);
        $andConditions['tv.property-price:>='] = $pinf.':numfield';
        $andConditions['tv.property-price:<='] = $psup.':numfield';
    }

    // propagate the http request variable for pagination
    $requests['pricerange'] = $pricerange;
};

$qhDeclaration = array(
    'qhVersion' => '1.2',
    'andConditions' => $andConditions,
    'requests' => $requests
);

$hook->setQueryHook($qhDeclaration);
return true;```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant