2

Apologies if I am dense, it won't be the first time.

I have thousands of product images that I will output on more than one page, under varying conditions. Rather than having to do an entry for each product in these circumstances, can I just:

  1. attach product description fields to the asset field
  2. upload the assets
  3. use Bob Olde Hampsink's import plug-in to populate all the product info to assets fields
  4. fetch the asset and the associated fields in a template
  5. skip the entry part altogether?

This way I could use the same asset in multiple instances without having to reinvent the wheel.

  A. Is this possible?
  B. Is this wise?
  C. If A and B =='yes' what is the most direct way to go about this?

1 Answer 1

2

Since there is several moving parts here, i'll make a few assumptions.

  1. You got a list of some kind with the product images and their containing metadata.
  2. Your product image filenames have a consistent naming scheme. Something like product-condition1-01,product-condition2-01, product-condition2-02
  3. You are able to write a couple PHP scripts and/or some frontend code that uploads your images, and then creates an list with the returned fileIds and the matching image filename. Take a look at AssetsService and the uploadFile action in AssetsController. For the uploading part, you can probably make a simple JS snippet that loops through the file list and uploads them.
  4. After you got that list, write a script that runs through the product list (an CSV or something), and replace the placeholders matching your image filenames (product-condition-xx etc.) with the previous fetched fileId(s).
  5. You will then end up with a comma-separated list of fileIds in your CSV fields, which Craft expects to able to relate the Assets to the imported Entries.
  6. Import the entries with Import.
  7. List the connected assets in your entries template the normal way.

I have not looked into how to save field info for Assets, but you can for sure make fields and then add them to the field layout for your Assets Sources.

(Not sure I understand all the conditions, but I think my outline should work pretty well for your case. Not able to comment yet, so I could not ask any questions beforehand. I'll update my answer if you add some follow-up information).

1
  • 1. Yes I have a CSV containing image names in one cell and has several other cells with product information. Woops hit enter by mistake, still replying! 2. The product image filenames do not, in all circumstances, yet have a consistent naming scheme, but a quick trip through a Photoshop action can fix that 3. I am not sure I follow this. Can I not simply upload the images into an asset folder and then use the.....Ah wait, I just went back and looked at the import plugin documentation, different than what was reported to me by an employee. I have to dig deeper. Thanks!
    – cmcjane
    Sep 16, 2014 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.