Skip to main content
1 of 2

This code resolved my need to backport production enabled-facet settings into localhost. Features are not used. tfk_search is the name of my module, substitute this for your own.

/**
 * Implement hook_form_FORM_ID_alter().
 *
 * Alter apachesolr_enabled_facets_form(), add an additional submit handler
 * that helps us export enabled facet settings via Features.
 */
function tfk_search_form_apachesolr_enabled_facets_form_alter(&$form, &$form_state, $form_id) {
  $form['#submit'][] = 'tfk_search_enabled_facets_form_submit';
}

/**
 * An additional submit handler for the active facets form.
 *
 * Save current settings into default server. Allows backporting
 * production settings into localhost. No Feature revert needed.
 *
 * @see apachesolr_enabled_facets_form
 */
function tfk_search_enabled_facets_form_submit($form, &$form_state) {
  $enabled = array();
  foreach ($form_state['values']['apachesolr_enabled_facets'] as $module => $facets) {
    $enabled[$module] = array_filter($facets);
  }
  
  // We hardcode 'solr' here because apachesolr_default_server() resolves to something
  // else in production.
  apachesolr_save_enabled_facets('solr', $enabled);
}