protected function loadAttributeValue($name, $attribute) {
    $query = Drupal::entityQuery('commerce_product_attribute_value');
    $result = $query->condition('name', $name)
      ->condition('attribute', $attribute)
      ->execute();

    // There should only ever be one value returned so we naively use the first
    // item in the array. This should generally be safe as this should only run
    // within a Drupal site install context.
    $attributeValue = NULL;
    if (count($result) > 0) {
      $attributeValue = ProductAttributeValue::load(reset($result));
    }

    return $attributeValue;
  }
protected function loadAttributeValue($name, $attribute) {
    $query = Drupal::entityQuery('commerce_product_attribute_value');
    $result = $query->condition('name', $name)
      ->condition('attribute', $attribute)
      ->execute();

    // There should only ever be one value returned so we naively use the first
    // item in the array. This should generally be safe as this should only run
    // within a Drupal site install context.
    $attributeValue = NULL;
    if (count($result) > 0) {
      $attributeValue = ProductAttributeValue::load(reset($result));
    }

    return $attributeValue;
  }
protected function loadAttributeValue ( $ name , $ attribute ) { $ query = Drupal :: entityQuery ( 'commerce_product_attribute_value' ) ; $ result = $ query -> condition ( 'name' , $ name ) -> condition ( 'attribute' , $ attribute ) -> execute ( ) ; // There should only ever be one value returned so we naively use the first // item in the array. This should generally be safe as this should only run // within a Drupal site install context. $ attributeValue = NULL ; if ( count ( $ result ) > 0 ) { $ attributeValue = ProductAttributeValue :: load ( reset ( $ result ) ) ; } return $ attributeValue ; }
Loads a product attribute value by attribute ID and name.

@param string $name
Attribute value name.
@param string $attribute
Attribute ID.

@return \Drupal\commerce_product\Entity\ProductAttributeValue|null
Loaded attribute value or NULL if one couldn't be found.
Loads a product attribute value by attribute ID and name .