If you make a view of all products with an exposed filter for the sell price field, enter some numbers in format like "1.45" and apply it to view result, in the view query result you will see that these numbers are trimmed to their integer part.

The Views module version is 6.x-2.6

Issue is posted in accordance with the Views' issues guidelines.

The query is:

SELECT node.nid AS nid,
   node.type AS node_type,
   node.title AS node_title,
   node.vid AS node_vid,
   uc_products.sell_price AS uc_products_sell_price
 FROM node node 
 LEFT JOIN uc_products uc_products ON node.vid = uc_products.vid
 WHERE (node.status <> 0) AND (node.type IN ('product','product_type_a')) AND (uc_products.sell_price >= 1) AND (uc_products.sell_price <= 2)
   ORDER BY node_title ASC

The exported view is:

$view = new view;
$view->name = 'uc_products_test';
$view->description = 'List of products plus price exposed filter.';
$view->tag = 'Ubercart products price filter';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'title' => array(
    'label' => 'Title',
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
  'field_image_cache_fid' => array(
    'label' => '',
    'link_to_node' => 1,
    'label_type' => 'widget',
    'format' => 'product_list_linked',
    'multiple' => array(
      'group' => 1,
      'multiple_number' => '1',
      'multiple_from' => '0',
      'multiple_reversed' => 0,
    ),
    'exclude' => 0,
    'id' => 'field_image_cache_fid',
    'table' => 'node_data_field_image_cache',
    'field' => 'field_image_cache_fid',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
  'sell_price' => array(
    'label' => 'Price',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'exclude' => 0,
    'id' => 'sell_price',
    'table' => 'uc_products',
    'field' => 'sell_price',
    'relationship' => 'none',
  ),
  'buyitnowbutton' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'exclude' => 0,
    'id' => 'buyitnowbutton',
    'table' => 'uc_products',
    'field' => 'buyitnowbutton',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
));
$handler->override_option('filters', array(
  'status' => array(
    'operator' => '=',
    'value' => 1,
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'relationship' => 'none',
  ),
  'is_product' => array(
    'operator' => '=',
    'value' => 1,
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'is_product',
    'table' => 'uc_products',
    'field' => 'is_product',
    'relationship' => 'none',
  ),
  'sell_price' => array(
    'operator' => '>=',
    'value' => array(
      'value' => '',
      'min' => '',
      'max' => '',
    ),
    'group' => '0',
    'exposed' => TRUE,
    'expose' => array(
      'use_operator' => 0,
      'operator' => 'sell_price_op',
      'identifier' => 'sell_price',
      'label' => 'Price:&nbsp;&nbsp;<span class="viewfilterlabelnobold">from</span>',
      'optional' => 1,
      'remember' => 0,
    ),
    'id' => 'sell_price',
    'table' => 'uc_products',
    'field' => 'sell_price',
    'relationship' => 'none',
  ),
  'sell_price_1' => array(
    'operator' => '<=',
    'value' => array(
      'value' => '',
      'min' => '',
      'max' => '',
    ),
    'group' => '0',
    'exposed' => TRUE,
    'expose' => array(
      'use_operator' => 0,
      'operator' => 'sell_price_1_op',
      'identifier' => 'sell_price_1',
      'label' => '<span class="viewfilterlabelnobold">to</span>',
      'optional' => 1,
      'remember' => 0,
    ),
    'id' => 'sell_price_1',
    'table' => 'uc_products',
    'field' => 'sell_price',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
  'role' => array(),
  'perm' => '',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('title', 'products type a');
$handler->override_option('items_per_page', 20);
$handler->override_option('use_pager', '1');
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
  'grouping' => '',
  'override' => 1,
  'sticky' => 0,
  'order' => 'asc',
  'columns' => array(
    'title' => 'title',
    'sell_price' => 'sell_price',
    'buyitnowbutton' => 'buyitnowbutton',
    'field_image_cache_fid' => 'field_image_cache_fid',
    'nid' => 'nid',
  ),
  'info' => array(
    'title' => array(
      'sortable' => 1,
      'separator' => '',
    ),
    'sell_price' => array(
      'sortable' => 1,
      'separator' => '',
    ),
    'buyitnowbutton' => array(
      'separator' => '',
    ),
    'field_image_cache_fid' => array(
      'separator' => '',
    ),
    'nid' => array(
      'sortable' => 1,
      'separator' => '',
    ),
  ),
  'default' => 'title',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'products_type_a');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
CommentFileSizeAuthor
#2 560890_filter_float.patch1.01 KBIsland Usurper

Comments

madsph’s picture

Changing the filter handler for ['uc_products']['sell_price'] from views_handler_filter_numeric to views_handler_filter_float in uc_product.views.inc should solve this.

Island Usurper’s picture

Status: Active » Needs review
StatusFileSize
new1.01 KB

Makes sense. I didn't notice views_handler_filter_float was an option before. views_handler_filter_numeric certainly doesn't make it explicit that it's only for integer types.

Island Usurper’s picture

Status: Needs review » Fixed

Makes so much sense that it works. :P Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.