function commerce_backoffice_get_vocabularies in Commerce Backoffice 7
Returns an array of vocabulary entities.
Parameters
$product_display: Boolean indicating whether to return vocabularies used by product display node types, or regular node types.
1 call to commerce_backoffice_get_vocabularies()
- commerce_backoffice_handler_filter_term_node_tid::value_form in includes/
views/ handlers/ commerce_backoffice_handler_filter_term_node_tid.inc - Options form subform for setting options.
File
- ./
commerce_backoffice.module, line 55
Code
function commerce_backoffice_get_vocabularies($product_display = FALSE) {
$fields = field_info_fields();
$product_display_node_types = commerce_product_reference_node_types();
if ($product_display) {
$node_types = $product_display_node_types;
}
else {
$all_node_types = node_type_get_types();
// Create a list of node types that are not product displays.
$node_types = array();
foreach ($all_node_types as $type => $node_type) {
if (!isset($product_display_node_types[$type])) {
$node_types[$type] = $node_type;
}
}
}
$voc_names = array();
foreach ($fields as $field) {
if ($field['type'] == 'taxonomy_term_reference' && isset($field['bundles']['node']) && array_intersect($field['bundles']['node'], array_keys($node_types))) {
$voc_names[$field['settings']['allowed_values'][0]['vocabulary']] = $field['settings']['allowed_values'][0]['vocabulary'];
}
}
if (!empty($voc_names)) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'taxonomy_vocabulary')
->propertyCondition('machine_name', $voc_names, 'IN');
$result = $query
->execute();
return taxonomy_vocabulary_load_multiple(array_keys($result['taxonomy_vocabulary']));
}
return array();
}