I can add an image to a product during creating using the following script. However, I'm having trouble loading a product and add additional image to the product media gallery. Do I have to delete the product media gallery and readd all the images at once? It's one image per row in a csv file.
public function addImage($product, $image)
{
$imagePath = $this->downloadImage($image);
$product->setMediaGallery(array('images' => array(), 'values' => array()));
if (is_file($imagePath)) {
$product->addImageToMediaGallery($imagePath, array('image', 'small_image', 'thumbnail'), false, false);
}
}