Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV Product Import - Images reporting failure. #2666

Closed
IceReaper opened this issue Dec 10, 2015 · 58 comments
Closed

CSV Product Import - Images reporting failure. #2666

IceReaper opened this issue Dec 10, 2015 · 58 comments
Labels
bug report Component: ImportExport Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update

Comments

@IceReaper
Copy link

Short:

Step1: Created a product by hand and exported it as csv file.
Step2: Deleted the product, so the Database is empty again.
Step3: Uploaded the images
Step4: Imported the csv file

[base|small|thumbnail|swatch]_image are working.
additional_images is empty and throwing this error:

Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in rows: ...

Long:

I've created a product by hand and exported it as CSV. I used that CSV file as pattern and added all the products.
I also uploaded the images in pub/media/import. I've put the first image as base_image small_image etc. and put every image again into the 'additional_images' column.
When pressing import (with correct image path entered) it finds all the images and copies them to pub/media/catalog/product. However it reports the following:

Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in rows: ...

Now comes the weird part: the base, small etc images are working. So the overview in frontend and backend are both having images. When editing the product, the gallery is empty. When entering the product detail-page, the images are missing.

When exporting the products again the base, small etc fields are correctly set, additional_images are empty. So something musts be broken with that field regarding the import feature.

I would fix it by myself but have no single clue where to start looking for that. So if anyone has a hint or maybe even a fix for this, i would be very thankful.

(Before anyone asks, got the same problem when importing the exported csv without adding further products)

@IceReaper
Copy link
Author

After a lot of digging i just found out that the images are correctly added to catalog_product_entity_media_gallery table but NOT to catalog_product_entity_media_gallery_value and catalog_product_entity_media_gallery_value_to_entity. Manualy adding those makes the images appear everywhere correctly. So the bug is simple: the relations between the images and the products will not be stored on csv import!

@eCommerceGorilla
Copy link

Is there any update on this issue yet? Any work arounds? Even a temp core hack to get product images in place would be great.

@eCommerceGorilla
Copy link

After some digging I came up with a solution. It seems the issue with permissions error is related to the local file system only and not remote systems. When running the import and pulling off from http://domain.com/pub/media/import/image.jpg it works when the same files error out with only /pub/media/import/image.jpg

Hope this helps someone.

@IceReaper
Copy link
Author

I managed to get around this after switching to PHP 7, did not manage to get around this on 5.6 - Runs perfectly on PHP7 in my case.

@jkristoffer
Copy link

I'm having the same problem when I try to import an image from a remote URL

@AddoSolutions
Copy link

+1 Same issue here. Tried manually specifying a path like var/import_media tried specifying pub/media/import and leaving it blank. Any ideas?

@Kdtv1977
Copy link

Kdtv1977 commented May 9, 2016

Hello Icereaper, I updated to PHP7 but I still don't see any images. So I have the same problem as described above : the base, small etc images are working. So the overview in frontend and backend are both having images. When editing the product, the gallery is empty. When entering the product detail-page, the images are missing.

How did you manage to work around and import the image if i may ask? Thx

@webspeaks
Copy link

Having same problem. Any update?

@IceReaper
Copy link
Author

As said, nothing ever worked, but then i tried to set the php version to 7.0 in the cpanel, and suddenly it worked. The switch to php 7.0 will have caused a different php.ini and extensions to be loaded, so it might be a php related setting.

@vzabaznov
Copy link
Contributor

Please, provide the used version. If the problem is actual for a specific branch, please, specify it and be sure that the latest update was used.

@davidnguyen2205
Copy link

It's still not working in 2.1.0 GA

@Ctucker9233
Copy link

I can confirm that.

@yssource
Copy link

yssource commented Jul 7, 2016

Still not working in 2.1.0

PHP 5.6.22 (cli) (built: May 26 2016 14:22:49) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with XCache v3.2.0, Copyright (c) 2005-2014, by mOo
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.3.3, Copyright (c) 2002-2015, by Derick Rethans
    with XCache Optimizer v3.2.0, Copyright (c) 2005-2014, by mOo
    with XCache Cacher v3.2.0, Copyright (c) 2005-2014, by mOo
    with XCache Coverager v3.2.0, Copyright (c) 2005-2014, by mOo

@yssource
Copy link

yssource commented Jul 7, 2016

It seems it should not import cvs file from the template being exported directly.
I am changing the value for all images from "/i/m/image.png" to be 'image.png' in the exported template csv file.
and place the uploading images in directory "/your_magento2_root/var/import/", then configure "Images File Directory" with relative path "var/import".
This is working for me.

@St0iK
Copy link

St0iK commented Aug 3, 2016

I am getting the same error message when i tried to import images from AWS.

Posting here in case someone experiences the same issue in the future.

After some digging, looks like it is failing because the my image links where containing a parameter

ex. ?1415800484

As a result on media/import the image names where like that:

screen shot 2016-08-03 at 11 14 05

and the Import was breaking.

@vkorotun vkorotun removed the MX label Aug 4, 2016
@rajabharathi22
Copy link

@vzabaznov Facing the same issue.

PHP 5.6.23 (cli) (built: Jun 26 2016 13:17:47)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

Cent-OS 6 on aws

@senthilengg
Copy link

senthilengg commented Aug 6, 2016

I have fixed it by running the below on magento root directory ...

Looks like the group or the user of apache/nginx does not have the permission to write on pub/media/catalog/product even if you don't have it on pub it will not allow you to write.

find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;
find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;

@magento-team

if you can add a log along with return false in the below function resides in

vendor/magento/module-catalog-import-export/Model/Import/Product.php

will help the developers to easily identify the issue.

protected function uploadMediaFiles($fileName, $renameFileOff = false)
    {
        try {
            $res = $this->_getUploader()->move($fileName, $renameFileOff);
            return $res['file'];
        } catch (\Exception $e) {
            $this->_logger->critical($e); // Added by senthil_m
            return '';
        }
    }

@oomta
Copy link

oomta commented Aug 7, 2016

My issue was resolved by ensuring all the URL's fetched from remote servers were properly URL encoded in my CSV.

In particular, the remote URL filenames had spaces in them. If you were to replace all space characters with %20, you'll be fine.

Hope that helps anybody else in the same boat as I was.

@ghost
Copy link

ghost commented Aug 24, 2016

receiving same message but for all images when importing from cvs file with images in pub/media/import folder.

@ghost
Copy link

ghost commented Aug 24, 2016

Not sure if this has anything to do with your issue as this is an internal import but I realized the CVS files should have no file path for the images. It should just be the image name.

In M2 I have images stored in pub/media/import but would get the same error 1. Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in row(s): 1, 2

I removed the path name from my CSV file and just have the image path as image.jpg with no slashes and it works great now.

@ghost
Copy link

ghost commented Sep 1, 2016

Can confirm that rosandrest's solution works, removing the external links altogether helped with 2.1

@koenner01
Copy link
Contributor

We had the exact same problem as explained here, but for us this had nothing to do with permissions or incorrect filepaths.

Using the suggestion from @senthilengg by logging the exception in the 'uploadMediaFiles' function, we came to the conclusion that our client had uploaded corrupt .jpg files.

In Magento\Framework\Image\Adapter\AbstractAdapter an exception was thrown in the 'validateUploadFile' function which caused the import to fail.

I think this issue can be closed as it is not Magento who is causing this issue.
The actual problems are caused by manual actions (ie. setting incorrect permissions, using faulty images, etc. ...). However, I do agree that logging and output are lacking quite a bit. Users could more easily spot their problems if the output was more accurate and closer to the actual problem.

@TomashKhamlai
Copy link
Contributor

@bacd there is internal ticket MAGETWO-58227 for your issue. This bug was fixed in 2.2 (branch 'develop')

@TomashKhamlai
Copy link
Contributor

@IceReaper, @davidnguyen2205, @davidnguyen2205, @Ctucker9233, @yssource, @St0iK, @brendanbell if this issue is actual for you try to import images on Magento v2.2.0.

It should work now. I can provide more details if somebody needs.

@korostii
Copy link
Contributor

korostii commented Jul 4, 2017

Hi @TomashKhamlai,
Is there a backport to 2.1.x planned for this fix?

If not, I'd suggest marking the issue with the up for grabs label so that someone from the community could notice it and consider putting some effort into a PR backporting the relevant commits (these are the ones, I assume) into 2.1-develop branch.

@magento-engcom-team magento-engcom-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Sep 18, 2017
@romeof1980
Copy link

romeof1980 commented Nov 6, 2017

hi @TomashKhamlai !
thanks for your clarification. Unfortunately we've been experiencing it in a fresh 2.2.0 too. It imports just 1 product (with its own images) then fails after that with the same error reported above (products' images placed in same local server in pub/media/import).
following the many suggestions above didn't lead to a solution.
could you please provide a hint?
thanks!

edited: in my case turned out to be an issue probably reported in #10209 Magento 2 import products with images using CSV Issue

@TomashKhamlai
Copy link
Contributor

Hello @romeof1980! You should be able to perform import on Magento 2.2.0. I think that you have problems in Step 5 of the instruction.
Instruction:

  1. Connect to your local or remote server using command line interface.
  2. Switch to the Magento file system owner
    (sudo su magento in my case). On Ubuntu 'magento' user is a member of the 'www-data' group. On CentOS 'magento' user is a member of 'apache' group. How to check this:
magento@TSG-215:/var/www/html/third$ groups ${whoami}
magento www-data

More information here: #mage-owner-about-group
3. Change your current folder to the folder where Magento was installed.
(/var/www/html/third in my case)
4. Create the folder for the images using the command:
mkdir -p var/import
5. Create a folder structure that can be viewed in pub/media/catalog/product after the product export. Here is what I've created.

magento@TSG-215:/var/www/html/third$ tree var/import
var/import
└── t
    └── -
        ├── t-shirt-mo-prob-lama_1.jpg
        ├── t-shirt-mo-prob-lama-back_1.jpg
        ├── t-shirt-mo-prob-lama-gallery_1.jpg
        └── t-shirt-mo-prob-lama-normal_1.jpg

2 directories, 4 files

I attached zip file with images t.zip. You can copy it by FTP to var/import folder and then unzip it.

magento@TSG-215:/var/www/html/third/var/import$ ls
t.zip
magento@TSG-215:/var/www/html/third/var/import$ unzip t.zip -d .
Archive:  t.zip
   creating: ./t/
   creating: ./t/-/
  inflating: ./t/-/t-shirt-mo-prob-lama-gallery_1.jpg  
  inflating: ./t/-/t-shirt-mo-prob-lama-normal_1.jpg  
  inflating: ./t/-/t-shirt-mo-prob-lama-back_1.jpg  
  inflating: ./t/-/t-shirt-mo-prob-lama_1.jpg  
magento@TSG-215:/var/www/html/third/var/import$ ls
t  t.zip
  1. Sometimes file permissions is a trouble you are not a Linux or Mac user.
    This is optional step but often helps:
find var/import -type f -exec chmod g+w {} \; && find var/import -type d -exec chmod g+ws {} \; && chown -R magento:www-data var/import
  1. Log in to Admin
  2. Open System -> Data Transfer -> Import
    Here is the screenshot of my import preparation.
    import-settings and zipped CSV file catalog_product_import.csv.zip
  3. Click 'Check Data' and perform import.

Expected result:
expected-result

@TomashKhamlai
Copy link
Contributor

Hello again. @romeof1980, I changed my mind. Pay more attention to step 2, and even much more to step 6.
Try to perform import without folder structure, but modify CSV. You need to edit the relative path to image files:
/t/-/t-shirt-mo-prob-lama-gallery_1.jpg => /t-shirt-mo-prob-lama-gallery_1.jpg
Images should be placed in var/import folder.

@karamsahu
Copy link

I was getting the same error, i fixed this. The solution was to have no spacial charechter, no space in the image file names. only alphabets and numbers. And it worked for me.

@iuli-dercaci
Copy link

so by summarising all the solutions I've seen here and in other places, I did the following:

  • updated magento from 2.2.1 to 2.2.3
  • removed all not alnum characters from the image names and forced it to lowercase 'Image-Name.jpg' > md5('Image-Name') . 'jpg'
  • changed the file owner to 'www-data' - chown www-data:www-data pub/media/import/*
  • changed image files permissions chmod 0755 pub/media/import/*.jpg

as a result - everything worked

PS if you following then do not forget to change image filenames to md5('Image-Name') . 'jpg' in your csv file

@alexguz79
Copy link

@site-me i have to say this is a dumb thing that most of us don't think about when uploading images.

I was banging my head for about an hour before finding this and realizing how easy it was.

@WindiceDev
Copy link

WindiceDev commented Apr 27, 2018

@site-me

Thanks a lot for the solution, i was stuck with this stupid image issue for over a week.

Can u just clarify one more doubt of mine, when u said remove all alnum characters do u mean no special characters also i mean like can we not use a "-" or "_" in the image name?

@iuli-dercaci
Copy link

@WindiceDev

I’ve noticed some recommendations about naming files which reported by several people as helpful, so I included this in my solution. Yes I left only numbers an letters in the file names (and an extension of course) by applying hash function which gives you exactly this set of characters

@Puru2016
Copy link

Puru2016 commented May 20, 2019

I am facing the same issue in Magento 2.3.1, To fix this I have follow the below steps:-

  • use the path var/import instead of /pub/media/import
  • Create a folder with import name, Set the full permission of var folder including import folder.
  • Confirm respective images are there in import folder.
  • Try to import the product using CSV.

Hope that helps you

@iyanuakins
Copy link

I encountered this problem too and i was able to solve it with the following steps:

  • Uploaded product images into /pub/media/import

  • In my CSV i used http://www.domain.com/pub/media/import/image_name.jpg without specifying the folder to upload to.

Hope this will help whosoever facing the same problem.

@vk-chts
Copy link

vk-chts commented Sep 10, 2019

Your image name should not have space or any special character to make it upload

@davidedmonson
Copy link

I realize this post is closed, but I wanted to add an update related to Magento ver. 2.3.2. I was running into this same error when uploading a csv that pulling a single image from an external url with no special characters or url related issues.
Imported resource (image) could not be downloaded from external resource due to timeout or access permissions

A quick check of the exception.log and I saw this:
[2019-11-20 23:59:35] main.CRITICAL: File directory 'pub/media/import' is not readable.

In my scenario, it was due to the pub/media/import directory missing completely. So, even if you are downloading a file from an external url, Magento uses the import directory to stage the file. Good to know.

@atulcodex
Copy link

Not sure if this has anything to do with your issue as this is an internal import but I realized the CVS files should have no file path for the images. It should just be the image name.

In M2 I have images stored in pub/media/import but would get the same error 1. Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in row(s): 1, 2

I removed the path name from my CSV file and just have the image path as image.jpg with no slashes and it works great now.

this idea not worked for me

@atulcodex
Copy link

THanks, problem solved

@usman786cs
Copy link

In Magento2.3.3 CE there is no need to specify the path. Just paste product images at /var/import/images/ directory and Images will be uploaded successfully

@kaushikrohit54
Copy link

I am using Magento 2.3.2 version and tried a lot to import products but best solution I found

  1. put your all images at pub/media/images/catalog/product/CUSTOM_DIR/1.jpg
    eg: /var/www/html/ocean-tableware/pub/media/catalog/product/lucaris

  2. In csv put base_image path as /CUSTOM_DIR/1.jpg
    /lucaris/1.png

While import from backend put path 'pub/media/import/

For more you can check here https://magento.stackexchange.com/a/325213/82482

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: ImportExport Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update
Projects
None yet
Development

No branches or pull requests