I am unable to make these filters working.

For example, I wish to filter options of the attribute "Mode de participation".
The option values are correctly displayed in the views field.
However, selecting a particular option that is present in the set clears the views.

I have noticed that the WHERE statement in Views is incorrect :
WHERE ((node_signup_log__uc_order_products.data) LIKE ('%s:21:\"Mode de participation\";a:1:{i:0;s:7:\"Webinar\";%')) AND (node_signup_log.nid = 4805 )

while in the ic_order_product table, the data field contents for the records that should appear is
a:6:{s:17:"uc_signup_enabled";i:1;s:10:"attributes";a:2:{s:21:"Mode de participation";a:1:{i:107;s:7:"Webinar";}s:10:"Membre SEE";a:1:{i:116;s:3:"Oui";}}s:9:"shippable";s:1:"0";s:12:"restrict_qty";b:0;s:6:"module";s:10:"uc_product";s:21:"uc_attributes_in_cart";s:4:"2192";}

Note
- Mode de participation";a:1:{i:107 in the database
- Mode de participation\";a:1:{i:0 in Views

If I manually change i:107 to i:0 in the database, the filter works.
Thanks for help

Comments

jvieille’s picture

Category: support » bug
Status: Active » Needs review

Found the problem.
In uc_views_attribute_hadler_filter_attr.inc
Function function query() {
(end of the fille)

    	if(!$optval) {
    	  //If we let the query get added, only products with the attribute enabled & with the value of that attribute empty
    	  //will return.  By default, I think it makes more sense to allow any product to return despite whether or not it
    	  //has the attribute if the user put nothing in to search for.
    	  //Adding a new type of filter that merely captures whether or not the attribute exists at all for the product may
    	  //be the best way to capture the alternative.  Or, perhaps a config option could be added to this filter :
    	  //"Show products only if they have this attribute enabled".  If this option is unchecked, a blank value returns all
    	  //products. If checked, a blank value at least filters out products that dont have this attribute available.
    	  continue;
    	}
-    	$var = array($key => array(0 => $optval));
+    	$var = array($key => array($value => $optval));
    	$servar = serialize($var);
    	$l = strpos($servar,'{')+1;
    	$r = strpos($servar,'}')-$l;
    	$value = substr($servar,$l,$r);
    	//@todo - this method of building the query does allow for partial text matching (i.e. 'foo' matches in 'foobar').
    	$this->query->add_where($this->options['group'], "$upper(%s) $not LIKE $upper('%%%s%%')", $field, $value);
    }
  }
}