public function CommerceProductReferenceSynonymsBehavior::extractSynonyms in Synonyms 7
Extract synonyms from an entity within a specific behavior implementation.
Parameters
object $entity: Entity from which to extract synonyms
string $langcode: Language code for which to extract synonyms from the entity, if one is known
Return value
array Array of synonyms extracted from $entity Array of synonyms extracted from $entity
Overrides SynonymsBehavior::extractSynonyms
File
- synonyms_commerce/
includes/ CommerceProductReferenceSynonymsBehavior.class.inc, line 13  - Enables Commerce Product Reference field type for synonyms integration.
 
Class
- CommerceProductReferenceSynonymsBehavior
 - Definition of CommerceProductReferenceSynonymsBehavior class.
 
Code
public function extractSynonyms($entity, $langcode = NULL) {
  $synonyms = array();
  $product_ids = array();
  foreach ($this
    ->entityItems($entity, $langcode) as $item) {
    $product_ids[] = $item['product_id'];
  }
  $entities = commerce_product_load_multiple($product_ids);
  foreach ($entities as $entity) {
    $synonyms[] = entity_label('commerce_product', $entity);
  }
  return $synonyms;
}