I am using below codes for the image save. It is working usually, but it doesn't work sometimes, it doesn't select image roles. How can I find the errors? Because Magento2 doesn't give an error.

$product = $this->repository->getById($productId, true, 0, true);

$types = ['images'];
if($image['is_default']) {
   $types = ['small_image', 'thumbnail', 'image'];
try {
   $product->addImageToMediaGallery($media_folder . $internal_url, $types, true, false);
} catch (\Throwable $exception) {
   return false;

I see the image in product detail. But I cannot see thumbnail image, because it doesn't select.

  • Do you get any JS erros in console
    – Ankit
    Jun 22, 2023 at 7:32
  • I am using SOAP API.
    – Zalmoxis
    Jun 22, 2023 at 13:07


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.