I am creating products with code and I am also adding images. This is the code:
$mediaArray = array(
'thumbnail' => $mainImage,
'small_image' => $mainImage,
'image' => $mainImage,
);
foreach($mediaArray as $imageType => $fileName) {
$filePath = $fileName;
if (file_exists($filePath)) {
try {
$product->addImageToMediaGallery($filePath, $imageType, false, true);
} catch (Exception $e) {
echo $e->getMessage();
}
}
}
Now this works, but they are not excluded from the gallery images. How would I do that?
Thanks!