申し訳ありませんが、私は 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) {}
ありがとうございました。