search fix

This commit is contained in:
merdan 2023-09-15 14:33:37 +05:00
parent 7bfcb58878
commit 1f58f19a76
2 changed files with 10 additions and 2 deletions

View File

@ -120,7 +120,7 @@ return [
'key' => env('MEILISEARCH_KEY', 'qazwsx12qazwsx12'), 'key' => env('MEILISEARCH_KEY', 'qazwsx12qazwsx12'),
'index-settings' => [ 'index-settings' => [
\Webkul\Product\Models\ProductFlat::class => [ \Webkul\Product\Models\ProductFlat::class => [
'filterableAttributes'=> ['locale', 'channel' ], // 'filterableAttributes'=> ['locale', 'channel' ],
'sortableAttributes' => ['name','created_at','min_price'], 'sortableAttributes' => ['name','created_at','min_price'],
// Other settings fields... // Other settings fields...
], ],

View File

@ -53,15 +53,23 @@ class ProductFlat extends Model implements ProductFlatContract
{ {
return 'products_index'; return 'products_index';
} }
public function searchable(): bool
{
return $this->status || $this->visible_individually;
}
public function toSearchableArray():array public function toSearchableArray():array
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'name' => $this->name, 'name' => $this->name,
'meta_keywords' => $this->meta_keywords, 'meta_keywords' => $this->meta_keywords,
'min_price' => $this->min_price,
'status' => $this->status, 'status' => $this->status,
'visible_individually'=> $this->visible_individually, 'visible_individually'=> $this->visible_individually,
'product_id' => $this->product_id 'product_id' => $this->product_id,
'created_at' => $this->created_at,
]; ];
} }
/** /**