$cart_data[] = [
'id' => $product->id,
'name' => $product->name,
- 'reference'=>$product->reference,
+ 'reference' => $product->reference,
'category' => $product->type->name,
'quantity' => $cart_items[$product->id],
'image' => $product->image,
$raw_products = Product::where('product_type', $product_type)->where('online', 1)->where('public', 1)->get();
$products = [];
+ $allids = [];
foreach ($raw_products as $idx => $raw_product) {
$products[$idx] = $raw_product->getPageData();
+ $allids[] = $products[$idx]->id;
}
$locale = App::getLocale();
foreach ($products as $product) {
$v = $product->get($spec_name);
+
+ if(null===$v){
+ $matching[] = $product->id;
+ continue;
+ }
+
if ($data->type == 'range') {
$f['min'] = min($f['min'], $v['first'] ?? INF, $v['second'] ?? INF);
$f['max'] = max($f['max'], $v['first'] ?? -INF, $v['second'] ?? -INF);
+
if (null !== $filter_value && !($v['first'] == '' && $v['second'] == '')) {
$min = min($v['first'], $v['second']);
$max = max($v['first'], $v['second']);
- if ($min <= $filter_value[1] && $max >= $filter_value[0]) {
+ if (null===$v || ($min <= $filter_value[1] && $max >= $filter_value[0])) {
$matching[] = $product->id;
}
}
$f['min'] = min($f['min'], $v);
$f['max'] = min($f['max'], $v);
if (null !== $filter_value) {
- if ($v >= $filter_value[0] && $v <= $filter_value[0]) {
+ if (null===$v || ($v >= $filter_value[0] && $v <= $filter_value[0])) {
$matching[] = $product->id;
}
}
$intersection = call_user_func_array('array_intersect', $all_matches);
}
- $res['results'] = ['count' => count($intersection), 'hits' => $intersection];
+ $res['results'] = ['count' => count($intersection), 'hits' => $intersection, 'notmatching' => array_diff($allids, $intersection)];
return $res;
}