modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Configurable.php
public function getAttributeValue($sku, $key) {
    $id = $sku instanceof SKUInterface ? $sku->id() : $sku;

    $query = \Drupal::database()->select('acm_sku__attributes', 'acm_sku__attributes');
    $query->addField('acm_sku__attributes', 'attributes_value');
    $query->condition("acm_sku__attributes.entity_id", $id);
    $query->condition("acm_sku__attributes.attributes_key", $key);
    return $query->execute()->fetchField();
  }
public function getAttributeValue($sku, $key) {
    $id = $sku instanceof SKUInterface ? $sku->id() : $sku;

    $query = \Drupal::database()->select('acm_sku__attributes', 'acm_sku__attributes');
    $query->addField('acm_sku__attributes', 'attributes_value');
    $query->condition("acm_sku__attributes.entity_id", $id);
    $query->condition("acm_sku__attributes.attributes_key", $key);
    return $query->execute()->fetchField();
  }
public function getAttributeValue ( $ sku , $ key ) { $ id = $ sku instanceof SKUInterface ? $ sku -> id ( ) : $ sku ; $ query = \ Drupal :: database ( ) -> select ( 'acm_sku__attributes' , 'acm_sku__attributes' ) ; $ query -> addField ( 'acm_sku__attributes' , 'attributes_value' ) ; $ query -> condition ( "acm_sku__attributes.entity_id" , $ id ) ; $ query -> condition ( "acm_sku__attributes.attributes_key" , $ key ) ; return $ query -> execute ( ) -> fetchField ( ) ; }
Get attribute value from key-value field.

@param int|\Drupal\acm_sku\Entity\SKUInterface $sku
Entity id of the SKU.
@param string $key
Name of attribute.

@return string|null
Value of field or null if empty.
Get attribute value from key - value field .