]> _ Git - pmi.git/commitdiff
fix #3009 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 12 Sep 2019 13:22:36 +0000 (15:22 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 12 Sep 2019 13:22:36 +0000 (15:22 +0200)
app/Models/Product.php

index af76904d0b7e3e38488651ae9794faa59b2a8bf3..c7043c156d23b72b20f239da7e4515e0d71b38e1 100644 (file)
@@ -479,13 +479,13 @@ class Product extends CubistMagicPageModel
                     $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'] = '';
@@ -511,7 +511,7 @@ class Product extends CubistMagicPageModel
                                 $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) {
@@ -519,6 +519,20 @@ class Product extends CubistMagicPageModel
                                 $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;