Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be able to filter the search enabled entities #181

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dist/src/Resources/config/search/taxons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ monsieurbiz_sylius_search:
app_taxon:
#prefix: '…' # define a custom index prefix on index names and aliases
#document_class: '…' # by default MonsieurBiz\SyliusSearchPlugin\Model\Documentable\Documentable
instant_search_enabled: true # by default false
#search_enabled: true # by default true
#instant_search_enabled: true # by default true
limits:
search: [9, 18, 27]
taxon: [9, 18, 27]
Expand Down
6 changes: 5 additions & 1 deletion src/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ public function searchAction(
);
$result = $this->search->search($requestConfiguration);

$documentableRegistries = array_filter($this->documentableRegistry->all(), function (DocumentableInterface $documentable) {
return (bool) $this->searchSettings->getCurrentValue($this->channelContext->getChannel(), null, 'search_enabled__' . $documentable->getIndexCode());
});

return $this->render('@MonsieurBizSyliusSearchPlugin/Search/result.html.twig', [
'documentableRegistries' => $this->documentableRegistry->all(),
'documentableRegistries' => $documentableRegistries,
'documentable' => $result->getDocumentable(),
'requestConfiguration' => $requestConfiguration,
'query' => urldecode($query),
Expand Down
3 changes: 2 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public function getConfigTreeBuilder(): TreeBuilder
->children()
->scalarNode('prefix')->defaultValue(null)->end()
->scalarNode('document_class')->defaultValue(Documentable::class)->end()
->scalarNode('instant_search_enabled')->defaultValue(false)->end()
->scalarNode('search_enabled')->defaultValue(true)->end()
->scalarNode('instant_search_enabled')->defaultValue(true)->end()
->scalarNode('source')->isRequired()->cannotBeEmpty()->end()
->scalarNode('target')->isRequired()->cannotBeEmpty()->end()
->scalarNode('mapping_provider')->defaultValue(YamlWithLocaleProvider::class)->end()
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/DocumentableRegistryPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ private function addDocumentableServices(ContainerBuilder $container, array $doc
$registry->addMethodCall('register', [$documentableServiceId, new Reference($documentableServiceId)]);

// Add the default settings value of documentable
$searchSettings['monsieurbiz.search']['default_values']['search_enabled__' . $indexCode] = $documentableConfiguration['search_enabled'];
$searchSettings['monsieurbiz.search']['default_values']['instant_search_enabled__' . $indexCode] = $documentableConfiguration['instant_search_enabled'];
$searchSettings['monsieurbiz.search']['default_values']['limits__' . $indexCode] = $documentableConfiguration['limits'];
}
Expand Down
3 changes: 2 additions & 1 deletion src/Resources/config/monsieurbiz_search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ monsieurbiz_sylius_search:
monsieurbiz_product:
#prefix: '…' # define a custom index prefix on index names and aliases
#document_class: '…' # by default MonsieurBiz\SyliusSearchPlugin\Model\Documentable\Documentable
instant_search_enabled: true # by default false
#search_enabled: true # by default true
#instant_search_enabled: true # by default true
limits:
search: [9, 18, 27]
taxon: [9, 18, 27]
Expand Down
Loading