You are here

function _webform_productfield_product_ids_from_type in Commerce Webform 7.2

Same name and namespace in other branches
  1. 8 productfield.inc \_webform_productfield_product_ids_from_type()

Get a list of all product ids of a given type(s).

Parameters

string|array $product_type: A product_type string or an array of product type strings

Return value

array An array of product ids.

2 calls to _webform_productfield_product_ids_from_type()
webform_conditional_prepare_productfield_type_js in ./productfield.inc
Prepare a conditional value for adding as a JavaScript setting.
_webform_productfield_product_ids in ./productfield.inc
Get a list of all the product_ids available to choose from on a productfield.

File

./productfield.inc, line 822

Code

function _webform_productfield_product_ids_from_type($product_type) {
  $products_ids = array();
  $query = new EntityFieldQuery();
  $result = $query
    ->entityCondition('entity_type', 'commerce_product')
    ->entityCondition('bundle', $product_type)
    ->execute();
  if (!empty($result['commerce_product'])) {
    $product_ids = array_keys($result['commerce_product']);
  }
  return $product_ids;
}