You are here

public function ProductVariation::getAttributeValues in Commerce Core 8.2

Gets the attribute values.

Return value

\Drupal\commerce_product\Entity\ProductAttributeValueInterface[] The attribute values, keyed by field name.

Overrides ProductVariationInterface::getAttributeValues

1 call to ProductVariation::getAttributeValues()
ProductVariation::generateTitle in modules/product/src/Entity/ProductVariation.php
Generates the variation title based on attribute values.

File

modules/product/src/Entity/ProductVariation.php, line 324

Class

ProductVariation
Defines the product variation entity class.

Namespace

Drupal\commerce_product\Entity

Code

public function getAttributeValues() {
  $attribute_values = [];
  foreach ($this
    ->getAttributeFieldNames() as $field_name) {
    $field = $this
      ->get($field_name);
    if (!$field
      ->isEmpty() && $field->entity) {
      $attribute_values[$field_name] = $field->entity;
    }
  }
  return $this
    ->ensureTranslations($attribute_values);
}