Answers.Body: <p>Since it sounds like you are using a third-party plugin for the initial import, you'll need a new plugin to handle the ftp uploads.
  This new plugin would need to perform the following:</p>
  
  <ul>
  <li>Basic control panel page, or Controller action for firing off the processing</li>
  <li>Get the list of new images files from the FTP directory</li>
  <li>For each file:
  
  <ul>
  <li>Parse the file name to get the associated vehicle stocknumber </li>
  <li>Query your vehicle entries based on the stock</li>
  <li>Use the Assets Service  (<a href="https://craftcms.com/classreference/services/AssetsService" rel="nofollow noreferrer">https://craftcms.com/classreference/services/AssetsService</a>) to
  create and store the asset appropriately</li>
  <li>Save the associated asset to the Vehicle Entry</li>
  </ul></li>
  <li>At the end of the run, archive/remove the original uploaded files</li>
  <li>Email the list of stocknumbers you have image files for but not existing entries (using EmailService)</li>
  </ul>
  
  <p>To further optimize the process/queries you could query all vehicles first and pull them out of an array by the stocknumber (instead of querying the DB each file).</p>
  
  <p>If you wanted to automate the process you could even build a task-listener to fire off your image-association plugin when it sees new images have been FTP'd to the vehicle image upload directory.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-17T17:45:35.637Z
Answers.LastActivityDate: 2017-02-17T17:45:35.637Z
Answers.UserDisplayName: ghoward
Body: <p>I have a potential client (car dealership) where in their existing 12 year old site they daily upload an Excel file to add/update/delete vehicles in stock. One file for new vehicles and one for used.</p>
  
  <p>However the excel file does not have a column for images and they are unwilling/unable to add one. Instead they want images to be added in the same way they currently are.</p>
  
  <p>All images are ftp'd up to the server and are named ##_stocknumber so 01_12345, 02_12345, 03_12345 would be attached to the same entry but 01_4455, 02_4455, 03_4455, 04_4455 would be attached to a different entry. After upload the go to a link that processes the images and then emails any stock numbers that are missing images. </p>
  
  <p>Is there some way that this can be achieved in Craft?</p>
  
Tags: <assets><image>
Title: Auto add Images to entry after ftp to server
ThreadText: # Auto add Images to entry after ftp to server
  
  (Asked by: username_0 on 2017-02-17)
  
  I have a potential client (car dealership) where in their existing 12 year old site they daily upload an Excel file to add/update/delete vehicles in stock. One file for new vehicles and one for used.
  
  However the excel file does not have a column for images and they are unwilling/unable to add one. Instead they want images to be added in the same way they currently are.
  
  All images are ftp'd up to the server and are named ##\_stocknumber so 01\_12345, 02\_12345, 03\_12345 would be attached to the same entry but 01\_4455, 02\_4455, 03\_4455, 04\_4455 would be attached to a different entry. After upload the go to a link that processes the images and then emails any stock numbers that are missing images.
  
  Is there some way that this can be achieved in Craft?
  
  **Tags:** assets, image
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-02-17. Score: 2
  
  Since it sounds like you are using a third-party plugin for the initial import, you'll need a new plugin to handle the ftp uploads.
  This new plugin would need to perform the following:
  
  * Basic control panel page, or Controller action for firing off the processing
  * Get the list of new images files from the FTP directory
  * For each file:
    + Parse the file name to get the associated vehicle stocknumber
    + Query your vehicle entries based on the stock
    + Use the Assets Service (<https://craftcms.com/classreference/services/AssetsService>) to
      create and store the asset appropriately
    + Save the associated asset to the Vehicle Entry
  * At the end of the run, archive/remove the original uploaded files
  * Email the list of stocknumbers you have image files for but not existing entries (using EmailService)
  
  To further optimize the process/queries you could query all vehicles first and pull them out of an array by the stocknumber (instead of querying the DB each file).
  
  If you wanted to automate the process you could even build a task-listener to fire off your image-association plugin when it sees new images have been FTP'd to the vehicle image upload directory.
  
  
  ---
  
  