You are here

protected function BpcDisplayTestCase::findDisplaysFor in Commerce Bulk Product Creation 7.2

Retrieves all display nodes referencing (at least) a given set of products.

Parameters

array $product_ids: An array of product IDs. Only display nodes that reference all these products will be returned.

string $type: (optional) The node type to which the search should be restricted. Defaults to 'product_display'.

Return value

array An array of fully-loaded node objects.

2 calls to BpcDisplayTestCase::findDisplaysFor()
BpcDisplayTestCase::displayExists in modules/bpc_display/bpc_display.test
Determines wether a display node exists that references all and only all the given products.
BpcDisplayTestCase::testSingleNodeCreation in modules/bpc_display/bpc_display.test
Tests the automatic creation of a single display node.

File

modules/bpc_display/bpc_display.test, line 254
Tests for Commerce BPC display node creation

Class

BpcDisplayTestCase
@file Tests for Commerce BPC display node creation

Code

protected function findDisplaysFor($product_ids, $type = 'product_display') {
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', $type);
  foreach ($product_ids as $id) {
    $query
      ->fieldCondition('field_product', 'product_id', $id);
  }
  $result = $query
    ->execute();
  if (!empty($result['node'])) {
    return entity_load('node', array_keys($result['node']));
  }
  else {
    return array();
  }
}