$options['-'] = ['label' => __('Non défini'), 'value' => '-', 'nb_products' => $values['-']];
}
$f['options'] = $options;
- } else if ($data->type == 'numeric' || $data->type == 'range') {
+ } else if ($data->type == 'numeric' || $data->type == 'range' || $data->type == 'numeric_list') {
$f['min'] = INF;
$f['max'] = -INF;
$f['unit'] = $data->unit;
$f['type'] = 'range';
- if ($data->type == 'numeric') {
+ if ($data->type == 'numeric' || $data->type == 'numeric_list') {
$f['prefix'] = $data['prefix'];
} else {
$f['prefix'] = '';
$matching[] = $product->id;
}
}
- } else {
+ } else if ($data->type == 'numeric') {
$f['min'] = min($f['min'], $v);
$f['max'] = max($f['max'], $v);
if (null !== $filter_value) {
$matching[] = $product->id;
}
}
+ } else if ($data->type == 'numeric_list') {
+ if (!is_array($v)) {
+ $v = [$v];
+ }
+ foreach ($v as $vv) {
+ $f['min'] = min($f['min'], $vv);
+ $f['max'] = max($f['max'], $vv);
+
+ if (null !== $filter_value) {
+ if (null === $vv || ($vv >= $filter_value[0] && $vv <= $filter_value[1])) {
+ $matching[] = $product->id;
+ }
+ }
+ }
}
if (null === $filter_value && $v != '') {
$matching[] = $product->id;