I am using better exposed filters(https://www.drupal.org/project/better_exposed_filters) and have created a price filter and the range I have selected is 0 to 2000.But I want the maximum limit of the price filter to be the maximum price of the product on that page(I have multiple pages with different products).

Is there a way to do it using views?


In view, add sort criteria for price filter i.e. Sort descending.


You can try this and add additional conditions based on your page count:-

* Implements hook_js_alter().
function hook_js_alter(&$javascript) {

 $query = new EntityFieldQuery();
 $query->entityCondition('entity_type', 'commerce_product')
 ->entityCondition('bundle', 'product') // replace with your bundle
 ->propertyCondition('type', 'product') // replace with your type
 $result = $query->execute();

 // Get the commerce product id for the max price
 $product_id = key($result['commerce_product']);
 $product =  commerce_product_load($product_id);

 $price = commerce_product_calculate_sell_price($product);
 $price = $price['amount']/100;

$settings = $javascript['settings']['data'];

foreach ($settings as $key => $value) {
  if (isset($settings[$key]['better_exposed_filters']['slider_options']['commerce_price_amount']['max'])) {
    $settings[$key]['better_exposed_filters']['slider_options']['commerce_price_amount']['max'] = $price;

$javascript['settings']['data'] = $settings;
  • js alter is cool but isn't there a way of doing it using views? – hardik19 Sep 23 '15 at 6:57
  • Not that i know of. Its a BEF module feature and they have added these options as javascript options. – Swarnendu Dutta Sep 23 '15 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.