Closed (fixed)
Project:
Commerce XLS Import
Version:
7.x-1.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
28 Sep 2016 at 03:59 UTC
Updated:
11 Aug 2017 at 21:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
travis-bradbury commentedCorrect. The files should be moved to the location specified in the field settings.
Correct. If you have folders in the zip archive you'll need to specify a relative path in the
field_imagecolumn but they'll be placed directly in thestore/picsfolder.It's also OK for the spreadsheet to reference an image that is not included in the zip archive if the image already exists in the destination.
Comment #3
armyofda12mnkeys commentedCool got it, thanks!
Comment #4
armyofda12mnkeys commentedactually one more question. if its 1 row in the import file per product/variation, for each variation pretend I have 5 pics (that I will upload at the same time via a zip file). How do those 5 paths get added to the 1 variation row in Excel?
Should i use comma separation or another format Commerce XLS Import recognizes?
Comment #5
travis-bradbury commentedYou should use commas to separate the file paths.
That applies to any multi-value fields you have. It uses
str_getcsv()when the field is multi-value so you can comma-separate and quote things in a standard way.Comment #6
armyofda12mnkeys commentedjust tested.
The rows without images got imported but rows with images paths could not.
I do see my images file got uploaded to: sites/default/files/product_images.zip
No unusual errors in php logs, just Commerse XLS Import errors like:
field_images: File store-temp/pics/IMG_2171.jpg does not exist.
tried non-relative path:
field_images: File /store-temp/pics/IMG_2171.jpg does not exist
Then tried without the zip file and upload directly to server be4 the import and got this:
field_images: File /home/username/theWebsite.com/sites/default/files/store-temp/pics/IMG_2171.jpg does not exist.
also tried these with the files already pre-uploaded to server:
sites/default/files/store-temp/pics/IMG_2171.jpg and
/sites/default/files/store-temp/pics/IMG_2171.jpg and
store-temp/pics/IMG_2171.jpg and
/store-temp/pics/IMG_2171.jpg
Any ideas (I'd prefer to use the zip upload) on why erroring?
Let me know and Ill give it a shot..
Also instead of using zip, if i just uploaded directly to the server, and use the server path... I assume it should be a temporary path so Drupal can name the file appropriately, like if my field_images filepath/filename is:
store/pics/nid-[commerce-product:field-product-node:0:nid]/product-id-[commerce-product:product-id]/[commerce-product:title]-[file:fid].[file:ffp-extension-original]
then it theoretically would move it from my store-temp/pics directory referenced in my Excel to my store/pics directory correct?
Comment #7
travis-bradbury commentedIs your zip file flat or does it have directories?
If the archive is flat, use "picture1.jpg", "picture2.jpg" in the import. You need to tell the import where to find the image when it extracts the zip archive and it'll look up the destination appropriate to the field it's being added to.
images.zip |-- picture1.jpg |-- foo |-- picture2.jpg |-- bar |-- baz |-- picture3.jpgIf you have directories in the zip archive you should be able to do "picture1.jpg", "foo/picture2.jpg", "bar/baz/picture3.jpg". This does not have to match the structure of the directories where the images will be moved to.
Comment #8
armyofda12mnkeys commentedWas using the relative structure. Not sure why it didn't work let me just try flat files in the zip and retest
Comment #9
armyofda12mnkeys commentedhey tbradbury,
I tried with relative paths (like when i was doing store-temp/pics/IMG_2171.jpg above ) and still no luck.
Tried with flat files in the zip (with no subfolders), and that worked.
Guess you can close unless worried relative paths still an issue.
Comment #10
travis-bradbury commentedThanks for reporting back, armyofda12mnkeys.
I see that the issue is in
CommerceXlsImportSettings::imagePath()- it only scans for files in the directory the images were extracted, not in sub-directories.Having reviewed it I think the function was doing a lot of things that aren't necessary. This patch cuts that down to just
file_exists(). I think it'll solve your problem if you still want your zip file to have sub-directories.Comment #11
travis-bradbury commentedChanging status to run tests.
Comment #12
armyofda12mnkeys commentedIts a bit further.
I tried uploading the zip file which has a directory structure of store/pics/test101.jpg, store/pics/test102.jpg, etc in the zip file.
and in the Commerce Excel template I had the same relative fields in field_images: store/pics/test101.jpg, etc
My Variation's field_images field is set to put the file to:
File (Field) Path settings
File path:
store/pics/product-id-[commerce-product:product-id]/
File name:
[commerce-product:title]-[file:fid].[file:ffp-extension-original]
I get this error when I try to Validate:
field_images: Unable to move file store/pics/test101.jpg to public://store/pics/store/pics/test101.jpg.
Looks like maybe its not even trying to move it under the appropriate place.
Any further ideas to debug?
Comment #13
travis-bradbury commentedI think this change to the patch will fix that - it should try to move the image to
public://store/pics/test101.jpginstead ofpublic://store/pics/store/pics/test101.jpgComment #14
armyofda12mnkeys commentedHey tbradbury,
I tested both going from:
store/pics/test101.jpg (in the zip)
to
store/pics/test101.jpg on the server and it works now (validates and imports correctly).
also tried FileField Paths for my field_images, so going from:
store/pics/test101.jpg (in the zip)
to:
store/pics/product-id-[commerce-product:product-id]/[commerce-product:title]-[file:fid].[file:ffp-extension-original]
and that also works great! Thanks!
Comment #15
Scott Robertson commentedRunning tests
Comment #16
Scott Robertson commentedOh wait, tests aren't set up haha. Are we running them via Travis CI now?
Comment #17
smccabe commentedYah, with the library requirements, you can't do them through DrupalCI since it doesn't have any concept of downloading libraries. So just run em locally or via TravisCI
Comment #18
kfitz commentedAdd patch to resolve the issue related to copying files over from tmp location.
Comment #19
dylf commentedRolled the previous two patches from #13 & #18 together against the latest dev.
Comment #21
smccabe commented