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

ISSUE-174: adds a fixed "10" rows limit while previewing any Entity Reference Search API (solr) views #175

Merged
merged 1 commit into from
May 21, 2024
Merged
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
16 changes: 11 additions & 5 deletions src/Plugin/views/display/EntityReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,7 @@ public function query() {
$search_api_query = $this->view->query;

$this->id_field_alias = $this->view->query->addField($id_table, $id_field);
if (!empty($this->view->live_preview)) {
// We hate blind Views on the UI. Give it a starting Match so we can
// see the logic happening
}


// Make sure the id field is included in the results.
$id_field = $this->view->storage->get('base_field');
Expand All @@ -185,7 +182,13 @@ public function query() {
'limit' => 0,
'ids_solr' => NULL,
];

$options += $default_options;
if (!empty($this->view->live_preview)) {
// Reduce the limit bc if Search API Server (solr) has a higher limit, e.g 10K for VBO
// the the preview will fail
if (!$options['limit' ]) { $options['limit' ] = 10; }
}

// Restrict the autocomplete options based on what's been typed already.
if (isset($options['match_solr']) && !empty($options['match_solr'])) {
Expand Down Expand Up @@ -215,7 +218,10 @@ public function query() {
if (!empty($options['ids_solr'])) {
$search_api_query->addWhere(0, $id_field, $options['ids_solr'], 'IN');
}
$this->view->setItemsPerPage($options['limit']);
// If someone programaticall already set (e.g Open API) a limit, don't set 0 as limit
if (!$this->view->getItemsPerPage()) {
$this->view->setItemsPerPage($options['limit']);
}
}

/**
Expand Down