这是使用 Magento 1.6.1 的 DataFlow 导入器的方法,从here得到它
- 所以你不要编辑核心文件,复制 app/code/local/Mage/Catalog/Model/Convert/Adapter/Product.php 到 app/code/ local/Mage/Catalog/Model/Convert/Adapter/
- 编辑 app/code/local/Mage/Catalog/Model/Convert/Adapter/Product.php 并在第 799 行之后添加以下内容:
if (isset($importData['media_gallery']) && !empty($importData['media_gallery'])) {
$x = explode(',', $importData['media_gallery']);
foreach ($x as $file) {
$imagesToAdd[] = array('file' => trim($file));
}
$mediaGalleryBackendModel->addImagesWithDifferentMediaAttributes(
$产品,
$imagesToAdd, Mage::getBaseDir('media') 。 DS 。 '进口',
错误的,
错误的
);
}
...所以你最终得到了这个:
793 $addedFilesCorrespondence = $mediaGalleryBackendModel->addImagesWithDifferentMediaAttributes(
794 $product,
795 $arrayToMassAdd, Mage::getBaseDir('media') . DS . 'import',
796 false,
797 false
798 );
799 /* http://www.magentocommerce.com/boards/viewthread/224928/P30/#t403196 */
800 if (isset($importData['media_gallery']) && !empty($importData['media_gallery'])) {
801 $x = explode(',', $importData['media_gallery']);
802 foreach ($x as $file) {
803 $imagesToAdd[] = array('file' => trim($file));
804 }
805
806 $mediaGalleryBackendModel->addImagesWithDifferentMediaAttributes(
807 $product,
808 $imagesToAdd, Mage::getBaseDir('media') . DS . 'import',
809 false,
810 false
811 );
812 }
如果您的 CSV 文件,添加一个名为 *media_gallery* 的列,并将您的其他图像放入 /media/import:
media_gallery
-------------
/s/e/second_image.png, /t/h/third_image.png,/f/o/fourth_image.png