I have configured the entity print views to print the search API results. The initial view uses a combination of facets and full text search for filtering the entities.

Entity print view only recognises the full text search; the facets are ignored. This makes sense, since the facet blocks aren't called on the print page. How can I include them there? Is there some other way to pass these parameters to search API?

Comments

Deno created an issue. See original summary.

Deno’s picture

Issue summary: View changes
Deno’s picture

Is there any way to include faceted filters in print view? Anyone?

Deno’s picture

Title: Entity print view doesn't acknowledge facet filters » How to pass facet filters to entity print?
Category: Bug report » Support request
Issue summary: View changes
Deno’s picture

Issue summary: View changes
olivier.br’s picture

You can do a query alter like there : https://www.drupal.org/project/facets/issues/2826650#comment-11871913
This code below works on my side, you need to adjust the search id names.

/**
 * Implements hook_search_api_query_alter().
 *
 * Fix pdf view query to use parent page facets.
 */
function YOURMODULE_search_api_query_alter(QueryInterface &$query) {
  if ($query->getIndex()->getServerInstance()->supportsFeature('search_api_facets')) {
    /** @var \Drupal\facets\FacetManager\DefaultFacetManager $facet_manager */
    $facet_manager = \Drupal::service('facets.manager');

    $search_id = $query->getSearchId();

    // If we have a pdf export that we need to filter.
    if (strpos($search_id, 'views_block:search_results__pdf_export_') === 0) {
      $search_id = 'search_api:views_page__search_results__page_1';

      // Add the active filters.
      $facet_manager->alterQuery($query, $search_id);
    }
  }
}
smustgrave’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs Review Queue Initiative

So believe views just prints what's in the view and since facets are probably placed by blocks they will have to be manually added.

Should be worth noting that facets 3.0.x is going towards integrating facets with view filters so those should get picked up.

This good to close?