I've placed a image file in the folder "pub/media/import" for product image, and run the below script, but I got an error message.
$fullImagePath = "pub/media/import/icn_status.png";
echo $fullImagePath;
if (file_exists($fullImagePath)) {
try {
$simple_product->addImageToMediaGallery($fullImagePath, array('image'), false);
} catch (Exception $e) {
echo $e->getMessage();
}
} else {
echo 'Can not find image';
}
ERROR:
[Magento\Framework\Exception\LocalizedException]
The image does not exist.
$simple_product->save();
after adding the images to the product ?