To my catalog grid ive added an extra column, which contains an attribute value, better said a color value.
Now I added a filter function with a dropdown.
This one looks like this:
protected function _colorFilter($collection, $column) {
if (!$value = $column->getFilter()->getValue()) {
return $this;
}
$field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
$cond = $column->getFilter()->getCondition();
$this->getCollection()->addFieldToFilter($field, $cond["eq"]);
return $this;
}
This works great, except it filters just for the values which are excactly the ones selected. That means: some fields have the value 140
, some 76
and some 33
.
When I select the value for 76
, it gives me all the products wich have the attribute-/color-value 76
. But what I want, are all the products wich have the value 76
, 76,140
, 76,33
, 76,140,33
.
I cannot find any way to perform this. Is this even possible with the function addFieldToFilter()
?