Last active
August 29, 2015 14:14
-
-
Save GoZOo/ba25413cfd9828d2a9e0 to your computer and use it in GitHub Desktop.
Drupal Commerce Get all known product displays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get all known product displays. | |
* | |
* We know they are product displays if they are node and have | |
* commerce_product_reference field type. | |
* | |
* @return array | |
* Array of bundle. | |
*/ | |
function _commerce_get_product_display_bundles() { | |
$target_bundles = &drupal_static(__FUNCTION__); | |
if (!isset($target_bundles)) { | |
$target_bundles = array(); | |
$fields = field_info_fields(); | |
foreach ($fields as $field) { | |
if ($field['type'] == 'commerce_product_reference' && isset($field['bundles']) && isset($field['bundles']['node'])) { | |
$target_bundles = array_merge($target_bundles, drupal_map_assoc($field['bundles']['node'])); | |
} | |
} | |
} | |
return $target_bundles; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment