Skip to content

Commit

Permalink
Configurable additional searchable attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
royduin committed Nov 10, 2021
1 parent 2bbb89c commit 80ec594
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions config/rapidez.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
'flushable_localstorage_keys',
],

// Additional searchable attributes with the search weight.
'searchable' => [
// 'attribute' => 4.0,
],

// With this token you can run commands from an url.
'admin_token' => env('RAPIDEZ_TOKEN', env('APP_KEY')),

Expand Down
10 changes: 6 additions & 4 deletions src/Http/ViewComposers/ConfigComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public function compose(View $view)

$configModel = config('rapidez.models.config');
$attributeModel = config('rapidez.models.attribute');
$searchableAttributes = Arr::pluck(
$attributeModel::getCachedWhere(fn ($attribute) => $attribute['search']),
'search_weight',
'code'
);

config(['frontend.locale' => $configModel::getCachedByPath('general/locale/code', 'en_US')]);
config(['frontend.currency' => $configModel::getCachedByPath('currency/options/default')]);
Expand All @@ -32,9 +37,6 @@ public function compose(View $view)
config(['frontend.show_swatches' => (bool) $configModel::getCachedByPath('catalog/frontend/show_swatches_in_product_list')]);
config(['frontend.translations' => __('rapidez::frontend')]);
config(['frontend.recaptcha' => Config::getCachedByPath('recaptcha_frontend/type_recaptcha_v3/public_key', null, true)]);

config(['frontend.searchable' => Arr::pluck($attributeModel::getCachedWhere(function ($attribute) {
return $attribute['search'];
}), 'search_weight', 'code')]);
config(['frontend.searchable' => array_merge($searchableAttributes, config('rapidez.searchable'))]);
}
}

0 comments on commit 80ec594

Please sign in to comment.