Jump to content

Is there a way to import product files/attachments?


indigo380

Recommended Posts

I have about a thousand products that we will be importing via csv. Each of these products has a different data sheet (PDF).

How can I import the product with the file/attachment? I didn't see a way to do it via import or API. I would be open to any modules that could do this as well.

Has anyone had any success with this before? I'm on Prestashop 1.7.

Link to comment
Share on other sites

Hi! 

You can refer to this thread - https://www.prestashop.com/forums/topic/349844-uploadable-files-pdf-attachment-in-csv-import/

However, code there is for Presta 1.6, so not sure if this works for 1.7. 

Alternatively, here is tutorial ho to import attachments with module - https://www.prestashopmanager.com/useful-articles/how-to/how-to-import-prestashop-product-attachments/ 

Link to comment
Share on other sites

  • 3 years later...

I'm sure the same logic may work for 1.7 but for my shop on 1.6.1.17 I can confirm the following works. I seen a few other ways but seemed quite complicated and involved modifying core files. Not sure how this works with multi-shops.

If you look at the below three tables you can fill out the data via excel and import the csv into phpMyAdmin for your site.

  1. ps_attachment - Details on file name and format
  2. ps_attachment_lang - Attachment name and description to display on front end
  3. ps_product_attachment - Ties the ID of the attachment to the product ID

!!!!!!!!!!!!!BACKUP ALL 3 TABLES ABOVE BEFORE IMPORTING!!!!!!!!!!!!!

How to import attachments with CSV and assign to product:

  1. Place all your files (JPG, ZIP, PDF etc.) into the downloads folder in the main shop directory. In my folder the filenames are encoded without an extension like "be7e7fa051951cf".
     
  2. Fill out the attached template and export each tab as CSV. 
    1. You may notice previously uploaded files added through the back end will show encoded text values under the column "file" in the phpMyAdmin database. For this just match these values to exactly the same as the filenames you uploaded to the download folder (YOURFILENAME.zip).
    2. Make sure to fill out the mime field. If you are unsure about the value needed, upload the file through the backend and then check the phpMyAdmin ps_attachment database for the latest ID. Your mime type value will be in the mime column such as "application/zip".
    3. To get the file sizes I used the following: https://discussions.apple.com/thread/2674721   - cd (drag folder into Terminal window, press return). Then: ls -l > ~/Desktop/list.txt
       
  3. BACKUP ALL 3 TABLES ABOVE BEFORE IMPORTING CSV INTO PHPMYADMIN
     
  4. MAKE SURE ALL 3 TABLES HAVE MATCHING IDs FOR EACH ATTACHMENT AND PRODUCT
     
  5. VOLA!

 

Import-Attachment-Template.xlsx

Edited by dirtrider118 (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...