$images =
$this->
checkDataReplacement( $variant->
getImages(),
$data,
'images',
true
);
foreach ($data['images'
] as $imageData) { // Check if a media id was passed.
if (isset($imageData['mediaId'
])) { // First check if the media object is already assigned to the product
$image =
$this->
getAvailableMediaImage( $article->
getImages(),
(int) $imageData['mediaId'
] );
// 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'
]);
if (!
$media) { throw new CustomValidationException(sprintf('Media by id %s not found',
(int) $imageData['mediaId'
]));
}