modules/acm_sku/src/Entity/SKU.php
public function getThumbnail() {
    $media = $this->getMedia();

    // We loop through all the media items and return the first image.
    foreach ($media as $media_item) {
      if (isset($media_item['media_type']) && $media_item['media_type'] == 'image') {
        return $media_item;
      }
    }

    return [];
  }
public function getThumbnail() {
    $media = $this->getMedia();

    // We loop through all the media items and return the first image.
    foreach ($media as $media_item) {
      if (isset($media_item['media_type']) && $media_item['media_type'] == 'image') {
        return $media_item;
      }
    }

    return [];
  }
public function getThumbnail ( ) { $ media = $ this -> getMedia ( ) ; // We loop through all the media items and return the first image. foreach ( $ media as $ media_item ) { if ( isset ( $ media_item [ 'media_type' ] ) && $ media_item [ 'media_type' ] == 'image' ) { return $ media_item ; } } return [ ] ; }
Function to return first image from media files for a SKU.

@return array
Array of media files.
Function to return first image from media files for a SKU .