You are here

public function CommerceContentEntityBase::getTranslatedReferencedEntity in Commerce Core 8.2

Gets the translation of a referenced entity.

Parameters

string $field_name: The entity reference field name.

Return value

\Drupal\Core\Entity\ContentEntityInterface|null The translated entity, or NULL if not found.

Overrides CommerceContentEntityInterface::getTranslatedReferencedEntity

5 calls to CommerceContentEntityBase::getTranslatedReferencedEntity()
Coupon::getPromotion in modules/promotion/src/Entity/Coupon.php
Gets the parent promotion.
Order::getStore in modules/order/src/Entity/Order.php
Gets the store.
OrderItem::getPurchasedEntity in modules/order/src/Entity/OrderItem.php
Gets the purchased entity.
ProductVariation::getAttributeValue in modules/product/src/Entity/ProductVariation.php
Gets the attribute value for the given field name.
ProductVariation::getProduct in modules/product/src/Entity/ProductVariation.php
Gets the parent product.

File

src/Entity/CommerceContentEntityBase.php, line 24

Class

CommerceContentEntityBase
Provides the base class for Commerce content entities.

Namespace

Drupal\commerce\Entity

Code

public function getTranslatedReferencedEntity($field_name) {
  $referenced_entities = $this
    ->getTranslatedReferencedEntities($field_name);
  $referenced_entity = reset($referenced_entities);
  return $referenced_entity ?: NULL;
}