// Media image isn't assigned to the product?
if(!$image){ // Find the media object and convert it to an product image.
$media = $this->getManager()->find(MediaModel::class, (int)$imageData['mediaId']);
$image = $this->getArticleResource()->createNewArticleImage($article, $media); } }elseif(isset($imageData['link'])){ // Check if an url passed and upload the passed image url and create a new product image.
$media = $this->getMediaResource()->internalCreateMediaByFileLink( $imageData['link'] ); $image = $this->getArticleResource()->createNewArticleImage($article, $media); }else{ thrownewCustomValidationException("One of the passed variant images doesn't contain a mediaId or link property!"); }