对不起,我是 php 的新手。下面的代码是允许您为每个产品导入多个图像。只需在导入文件中添加一个“图库”列,并用分号分隔每个图像。导入数据来自.csv 文件。但有一个错误。如果我已经导入了图像,当我再次导入时,它仍然会再次导入。当然,产品有很多重复的图像。如果产品已经导入了图像,如何防止它再次导入。
try {
$galleryData = explode(';',$importData["gallery"]);
foreach($galleryData as $gallery_img)
/**
* @param directory where import image resides
* @param leave 'null' so that it isn't imported as thumbnail, base, or small
* @param false = the image is copied, not moved from the import directory to it's new location
* @param false = not excluded from the front end gallery
*/
{
$product->addImageToMediaGallery(Mage::getBaseDir('media') . DS . 'import' . $gallery_img, null, false, false);
}
}
catch (Exception $e) {}
谢谢你。