I've been successful in mapping/importing products with a File field using (many thanks!) the documentation found at http://www.drupalcommerce.org/comment/reply/467#comment-form, but have not been able to map to a Commerce File field. It does not appear as a target.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | commerce_feeds_commerce_file-1249114-7.patch | 4.57 KB | jonathan_hunt |
| #2 | commerce_feeds.module.patch | 485 bytes | rennevat |
| #2 | commerce_file.inc_.patch | 3.32 KB | rennevat |
Comments
Comment #1
rfayYes, I'm pretty sure we'll have to add that as a mapping. Thanks for pointing that out. Patches are welcome.
Comment #2
rennevat commentedFirst attempt. The new commerce_file.inc for commerce_feeds/mappers comes from http://drupal.org/node/1162602#comment-4581266. The import is uploading the images and zip files but fails on importing the products and returns
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'field_commerce_file_data' cannot be nullComment #3
rfayI assume you're having to make changes in both commerce_file and commerce_feeds? If so, please post to an issue in commerce_file and crossreference it here.
Setting to "Needs review"
Comment #4
pcambraI think that both patches attached by rennevat are for commerce_feeds module.
Keeping it as needs review as I'd like to review and test this with more detail.
Comment #5
discipolo commentedthey are for commerce_feeds. but i think the code at http://drupal.org/node/1162602#comment-4581266 was supposed to import files that are already in the files table by their fid without duplicating them
the patch in #2 uses the files path and creates a fileduplicate
Comment #6
Stolinski commentedWhat's the status of this? Importing a file to a commerce file field is an essential feature.
Comment #7
joelrosen commentedManaged to piece together this snippet in my own custom FeedsProcessor by looking through the code from Commerce File. Seems to be creating Commerce File fields properly. Here, $new_product is a Commerce Product with a Commerce File field named "field_image_file" on it, and $filename is the full path to the file I want to sell access to:
Not sure if I did this properly... but seems to be working fine.
Comment #8
jonathan_hunt commentedThe attached patch builds on #2. Key changes are (a) always using private:// for the target file destination (this is what Commerce File defaults to), though it would be better if Commerce File exposed an API so that the scheme can be queried, and (b) attaching license data to the file (this is the "'field_commerce_file_data' cannot be null" error @rennevat ran into. I'm sure the code can be improved further, but it is working for me now.
One caveat is that files to be imported need to be reachable by drupal_http_request - this may not always be the case for file:// for example. My work around at present is to upload files (e.g. using sftp) into a path within public://
Comment #9
recrit commentedfeeds support has been added natively to Commerce File at #1162602: Feeds support for Commerce File
Comment #10
jonathan_hunt commentedThat's great news, thanks. Shame that there has been duplicated effort. Setting this to won't fix with respect to Commerce Feeds.