modules/acm_sku/src/Entity/SKU.php
public function getMedia($download_media = TRUE, $reset = FALSE) {
    if (!$reset && !empty($this->mediaData)) {
      return $this->mediaData;
    }

    if ($media_data = $this->get('media')->getString()) {
      $update_sku = FALSE;

      $media_data = unserialize($media_data);

      if (empty($media_data)) {
        return [];
      }

      foreach ($media_data as &$data) {
        // We don't want to show disabled images.
        if (isset($data['disabled']) && $data['disabled']) {
          continue;
        }

        $media_item = $this->processMediaItem($update_sku, $data, $download_media);

        $this->mediaData[] = $media_item;
      }

      if ($update_sku) {
        $this->get('media')->setValue(serialize($media_data));
        $this->save();
      }
    }

    return $this->mediaData;
  }
public function getMedia($download_media = TRUE, $reset = FALSE) {
    if (!$reset && !empty($this->mediaData)) {
      return $this->mediaData;
    }

    if ($media_data = $this->get('media')->getString()) {
      $update_sku = FALSE;

      $media_data = unserialize($media_data);

      if (empty($media_data)) {
        return [];
      }

      foreach ($media_data as &$data) {
        // We don't want to show disabled images.
        if (isset($data['disabled']) && $data['disabled']) {
          continue;
        }

        $media_item = $this->processMediaItem($update_sku, $data, $download_media);

        $this->mediaData[] = $media_item;
      }

      if ($update_sku) {
        $this->get('media')->setValue(serialize($media_data));
        $this->save();
      }
    }

    return $this->mediaData;
  }
public function getMedia ( $ download_media = TRUE , $ reset = FALSE ) { if ( ! $ reset && ! empty ( $ this -> mediaData ) ) { return $ this -> mediaData ; } if ( $ media_data = $ this -> get ( 'media' ) -> getString ( ) ) { $ update_sku = FALSE ; $ media_data = unserialize ( $ media_data ) ; if ( empty ( $ media_data ) ) { return [ ] ; } foreach ( $ media_data as & $ data ) { // We don't want to show disabled images. if ( isset ( $ data [ 'disabled' ] ) && $ data [ 'disabled' ] ) { continue ; } $ media_item = $ this -> processMediaItem ( $ update_sku , $ data , $ download_media ) ; $ this -> mediaData [ ] = $ media_item ; } if ( $ update_sku ) { $ this -> get ( 'media' ) -> setValue ( serialize ( $ media_data ) ) ; $ this -> save ( ) ; } } return $ this -> mediaData ; }
Function to return media files for a SKU.

@param bool $download_media
Whether to download media or not.
@param bool $reset
Flag to reset cache and generate array again from serialized string.

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