You are here

public function ProductHandler::getProductImageUrl in Mailchimp E-Commerce 8

@inheritdoc

File

src/ProductHandler.php, line 165

Class

ProductHandler
Product handler.

Namespace

Drupal\mailchimp_ecommerce

Code

public function getProductImageUrl($product) {
  $image_url = '';
  $config = \Drupal::config('mailchimp_ecommerce.settings');
  $image_field_name = $config
    ->get('product_image');
  if (isset($product->{$image_field_name}->entity)) {
    $image_url = $product->{$image_field_name}->entity
      ->url();
  }
  return $image_url;
}