Magento1 Image not exist

Magento 1: Image does not exist when importing products

Recent days, I work on a project to rebuild a magento website to optimize its performance and improving customer experience. Our team decided to migrate data to a fresh magento community 1.9.3.0 (latest magento 1.9 version).

It is a common practice to use Magento Data Flow Profiles for importing data.

System -> Import / Export -> Data Flow Profiles -> Import All Products

import_products_media

When running the profile for importing product data, I met a series of errors

Image does not exist.

They look like this:

images does not exists

The CSV file was exported from old magento system, it has this template:

sku,image
"Product-001","/p/o/filename.jpg"

Mage_Catalog_Model_Convert_Adapter_Product will call saveImageDataRow for saving product image:

/**
     * Save data row with gallery image info only
     *
     * @param Mage_Catalog_Model_Product $product
     * @param array $importData
     *
     * @return Mage_Catalog_Model_Convert_Adapter_Product
     */
    public function saveImageDataRow($product, $importData)
    {
        $imageData = array(
            'label'         => $importData['_media_lable'],
            'position'      => $importData['_media_position'],
            'disabled'      => $importData['_media_is_disabled']
        );

        $imageFile = trim($importData['_media_image']);
        $imageFile = ltrim($imageFile, DS);
        $imageFilePath = Mage::getBaseDir('media') . DS . 'import' . DS . $imageFile;

        $updatedFileName = $this->_galleryBackendModel->addImage($product, $imageFilePath, null, false,
            (bool) $importData['_media_is_disabled']);
        $this->_galleryBackendModel->updateImage($product, $updatedFileName, $imageData);

        $this->_addAffectedEntityIds($product->getId());
        $product->setIsMassupdate(true)
            ->setExcludeUrlRewrite(true)
            ->save();

        return $this;
    }

The absolute file path to check for existed image is defined by this line:

$imageFilePath = Mage::getBaseDir('media') . DS . 'import' . DS . $imageFile;

It means, the function will check for media/import/p/o/filename.jpg  for the existed file so I copied all the data from media/catalog/product folder, if you have ssh access  to the server, you can have it done with some simple commands.

cd docroot/media
mkdir import
rsync -av catalog/product/ import/

After that, I could import thousand of products successfully.

If you have only FTP access, you may upload it to media/import then it will work.

I hope this small tip can help you to save time of debugging the issue.