1,12d0 < From 51e8a114f9c1673e7c2df470693c3b15376376b2 Mon Sep 17 00:00:00 2001 < From: Artem Kolotilkin < Date: Tue, 15 Dec 2015 23:50:58 -0500 < Subject: [PATCH] Issue #1269608: Integrate Search API with Addressfield < < --- < addressfield.info | 1 + < addressfield.module | 14 +++++++++ < includes/processor_addressfield.inc | 59 +++++++++++++++++++++++++++++++++++++ < 3 files changed, 74 insertions(+) < create mode 100644 includes/processor_addressfield.inc < 49c37 < index 0000000..4810b14 --- > index 0000000..dd82bbf 52c40 < @@ -0,0 +1,59 @@ --- > @@ -0,0 +1,93 @@ 61,62c49,50 < + * Processor for appending full text value of administrative_area (state) < + * to its abbreviation (i.e., "CA" => "CA California"). --- > + * Processor for replacing the abbreviation of administrative_area (state) > + * for its full text value (i.e., "CA" => "California"). 71,72c59,60 < + as it only appends full text value of administrative_area (state) to its abbreviation < + (i.e., "CA" => "CA California").

--- > + as it only replaces the abbreviation of administrative_area (state) for its full text > + value (i.e., "CA" => "California").

81a70,74 > + > + $reference_types = array('taxonomy_term_reference', > + 'entityreference', > + 'commerce_product_reference'); > + 84c77 < + // Don't preprocess the field with an empty value --- > + // Don't preprocess the field with an empty value. 89c82 < + // Only process fields of addressfield type --- > + // Only process fields of addressfield type. 92c85 < + // Process administrative_area (State) sub-field --- > + // Process administrative_area (State) sub-field. 95c88 < + // Get country code --- > + // Get country code. 100a94,122 > + // Append administrative_area full value to abbreviation. > + $field['value'] = $administrative_areas[$field['value']]; > + $this->processField($field['value'], $field['type']); > + } > + } > + } > + else if (!empty($field_info) && in_array($field_info[$field_name[0]]['type'], $reference_types)) { > + > + /* > + * Reference to an entity type that could have an addressfield. > + */ > + $last_two = array(); > + $last_two[] = array_pop($field_name); > + $last_two[] = array_pop($field_name); > + $field_name = array_reverse($last_two); > + $field_info = field_read_fields(array('field_name' => $field_name[0])); > + > + if (isset($field_name[1]) && $field_name[1] == "administrative_area") { > + // Get country code > + $field_name_country = explode(":", $name); > + array_pop($field_name_country); > + array_push($field_name_country, 'country'); > + $field_name_country = implode(':', $field_name_country); > + > + $country_code = reset(explode(" ", $item[$field_name_country]['value'])); > + module_load_include('inc', 'addressfield', 'addressfield.administrative_areas'); > + $administrative_areas = addressfield_get_administrative_areas($country_code); > + > + if (!empty($administrative_areas)) { 102c124 < + $field['value'] .= " " . $administrative_areas[$field['value']]; --- > + $field['value'] = $administrative_areas[$field['value']]; 113,115d134 < -- < 2.6.2 <