All sorts of fun this week at Will Hall Online trying to use the Drupal Commerce Feeds module to import several hundred images on to a site. Initially our thoughts had been to manage file uploads via the IMCE module, but once the data requirements of our client became clear it was apparent that a more efficient solution was needed. Here's what we did:
- Created a new directory on our server to contain these images
- Moved the images across from their original location inside sites/default, then removed them from the standard file system, including thumbnails.
- Created an extra column on our product data CSV file containing the new URL for each product's image.
- Mapped that column onto the product image field on the site.
We then deleted all of the existing product data on the site to give us a fresh start and reimported the data. Products uploaded successfully. Images now present on the site's filesystem. Less so on the site's front-end. Those of you familiar with Commerce Feeds and in possession of a close attention to detail might be able to see why already.
We, however, were initially stumped. URLs and field names were double checked. Heads were scratched. We noticed that the product content type was set up to store the images in a subdirectory including a typo, which we thought shouldn't have made much difference, but we corrected it and tried again. Still no joy.
The eventual solution, as the more eagle-eyed among you have doubtless spotted, was to change the file source of the product image field back to upload instead of IMCE. This was discovered through the creation of a rather nifty (if we do say so ourselves) view that checked the relationships between each product title and its associated image(s). What the view showed was that in most cases, there was no relationship because the product was only being connected with images uploaded via the IMCE.
With the altered file source, the images are now all present and correct and our client can use SFTP to upload any new product images to the server, then add the URL to the product data for import. Hope this might help one or two readers in the future!
Happy 2015, fellow Drupallers. Until next time