Search API Addressfield Country Name
Categories
Component ID
2918919
Component name
Search API Addressfield Country Name
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
What's this module for?
This module adds a Search API field processor which converts the 2-letter country code into the full country name for the Country component of an Address field.
Motivating for creating the module
When creating a View based on the search index, I was able to select the country as a field and use the "Use human-readable name" checkbox to render the full country name. But when adding an exposed Sort field for country, the view would sort records by their country code. That created a problem where Germany (DE) would always appear before France (FR). Using this module to convert the 2-letter country code into the full country name causes sorting to work correctly on the country name.
How to use it
- Create a Search API index for a node/entity that contains an Address field (i.e. "Postal Address" on the fields page).
- On the Fields tab, select the country component to be indexed as a String (e.g. "Address » Country").
- On the Filters tab under the Processors section, click "Address field: Convert country code to name", then scroll down to Processor Settings and select the Country field (from step 2).
- Re-index your items.
- Edit your view to add the Country field as an exposed sort field.