|
@@ -341,15 +341,25 @@ class FilterableAttributesProvider implements ProviderInterface
|
|
|
$column = $this->columnForType($attributeType);
|
|
$column = $this->columnForType($attributeType);
|
|
|
$term = (string) $spec['match'];
|
|
$term = (string) $spec['match'];
|
|
|
$matchType = $spec['match_type'] ?? '';
|
|
$matchType = $spec['match_type'] ?? '';
|
|
|
|
|
+ $isMultiValue = in_array($attributeType, ['multiselect', 'checkbox'], true);
|
|
|
|
|
|
|
|
- $countQuery->whereIn('pav.product_id', function ($sub) use ($code, $column, $term, $matchType) {
|
|
|
|
|
|
|
+ $countQuery->whereIn('pav.product_id', function ($sub) use ($code, $column, $term, $matchType, $isMultiValue) {
|
|
|
$sub->select('product_id')
|
|
$sub->select('product_id')
|
|
|
->from('product_attribute_values as pav_facet')
|
|
->from('product_attribute_values as pav_facet')
|
|
|
->where('pav_facet.attribute_id', function ($q) use ($code) {
|
|
->where('pav_facet.attribute_id', function ($q) use ($code) {
|
|
|
$q->select('id')->from('attributes')->where('code', $code);
|
|
$q->select('id')->from('attributes')->where('code', $code);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- if ($matchType === 'PARTIAL') {
|
|
|
|
|
|
|
+ if ($isMultiValue) {
|
|
|
|
|
+ // multiselect/checkbox store comma-separated option ids in text_value.
|
|
|
|
|
+ $values = array_values(array_filter(array_map('trim', explode(',', $term))));
|
|
|
|
|
+
|
|
|
|
|
+ $sub->where(function ($q) use ($column, $values) {
|
|
|
|
|
+ foreach ($values as $value) {
|
|
|
|
|
+ $q->orWhereRaw("FIND_IN_SET(?, pav_facet.{$column})", [$value]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } elseif ($matchType === 'PARTIAL') {
|
|
|
$sub->where('pav_facet.'.$column, 'like', "%{$term}%");
|
|
$sub->where('pav_facet.'.$column, 'like', "%{$term}%");
|
|
|
} elseif (str_contains($term, ',')) {
|
|
} elseif (str_contains($term, ',')) {
|
|
|
$values = array_values(array_filter(array_map('trim', explode(',', $term))));
|
|
$values = array_values(array_filter(array_map('trim', explode(',', $term))));
|
|
@@ -411,7 +421,8 @@ class FilterableAttributesProvider implements ProviderInterface
|
|
|
{
|
|
{
|
|
|
return match ($attributeType) {
|
|
return match ($attributeType) {
|
|
|
'text', 'textarea' => 'text_value',
|
|
'text', 'textarea' => 'text_value',
|
|
|
- 'select', 'multiselect', 'dropdown' => 'integer_value',
|
|
|
|
|
|
|
+ 'select', 'dropdown' => 'integer_value',
|
|
|
|
|
+ 'multiselect', 'checkbox' => 'text_value',
|
|
|
'decimal', 'price' => 'float_value',
|
|
'decimal', 'price' => 'float_value',
|
|
|
'integer' => 'integer_value',
|
|
'integer' => 'integer_value',
|
|
|
'boolean' => 'boolean_value',
|
|
'boolean' => 'boolean_value',
|