0

I've got a Drupal 7 site with 2 Search API indexes:

  1. DB-based index (legacy)
  2. SOLR-based index (new)

I've got an index alter callback defined like this:

/**
 * Implements hook_search_api_alter_callback_info().
 */
function commerce_products_search_api_alter_callback_info()
{
  return [
    'commerce_products_alter_add_facets' => [
      'name' => t('Add facets fields'),
      'description' => t('Automatically add all facets fields of the datasheets.'),
      'class' => '\Drupal\commerce_products\Facetapi\AlterAddFacets',
    ],
  ];
}

In class AlterAddFacets, I'm adding facet fields based on some data like this:

$fields['products_facet_' . $facetItem['id']] = [
        'label' => $title,
        'dependency plugins' => array('role', 'commerce_products_category_dependency'),
      ];

This works fine for bot indexes. However, dependency defined with:

/**
 * Implements hook_facetapi_dependencies().
 */
function commerce_products_facetapi_dependencies()
{
  return [
    'commerce_products_category_dependency' => [
      'handler' => [
        'label' => t('Commerce Category Facetapi Dependency'),
        'class' => '\Drupal\commerce_products\Facetapi\DependencyCategory', /* @var $var \Drupal\commerce_products\Facetapi\DependencyCategory */
      ],
    ],
  ];
}

works only for legacy DB index. When I added a breakpoint to DependencyCategory::execute, the code is executed (by xDebug) only for fields defined in DB index, not for fields in the SOLR index. How can I debug this further?

I'm using latest versions of SearchAPI and Search API Solr Search modules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.