ich write my script for adding new products and edit products into our magento shop. I have this code for the images (will will have one image per product only)
$image_file = Mage::getBaseDir('media') . DS . 'import/' . $data[$header_line['image']];
mediaArray = array('thumbnail' => $image_file, 'small_image' => $image_file, 'image' => $image_file);
foreach($mediaArray as $imageType => $fileName)
{
if ( file_exists($fileName) )
{
$product->addImageToMediaGallery($fileName, $imageType, false);
}
}
That code works and magento will add the image. But when I restart my process this codes run as well es edit function and the images will add again. Now the product has more images and all are the same.
The best way would be to update the images, when it was changes, but I think magento is not possible to this.
Then i think the best way would be to replace/update the image and not add a new one. Is this possible?
Is there any other way?
Best regards
Aucun commentaire:
Enregistrer un commentaire