Conceptual Question: Import Images to Shopware

  • answers in german welcome -

Hi there,

i am very new to shopware and i am into writing a syncronization plugin between an external article database to shopware. So far so good it works really fine.

The Problem is the image import and i ask you to figure out the best way to do this, thanks in advance!


  • Import every day
  • Datas on external MySQL Database
  • Files on a network storage accessable via url
  • Database not responsible for images

The Importer yet:

To keep resources down i implemented a table storing the hash values of the last import. So i am able to detect changes to perform an update or create in the shopware db.

The case is that the images do not change the external database. The workflow to change an image is to rename the file to the .jpg copy it to the network storage in a predefined folder structure. Done. (I know this is a big point of failure but thats how it is).

Problem: No way to detect changes of images from the hashed external database rows.


  • only import images when they changed
  • keep resource consumption low

My solution of the image import:

I will do a second hash table of the files. If a file changes, the hash value will be change so the plugin can detect changes of a file. Then import the files via the article Resource by sending an array like this:

        array('link' => '".$articleID.".jpg"),
    '__options_images' => array('replace' => true)

$article = $articleResource->updateByNumber($articleID, $articleUpdate);

Shopware will now download the image and import it correctly. Conserns i have with this is that shopware will delete old pictures and replace it with the new ones. If i don’t care about changed images a solution is to import every day all images. Over 1000 images for me this is not a common solution because shopware will delete all medias and create new ones, every day.

My questions:

  1. Is this a propper way to solve the problem:
  • Detect changes as fast as posible with a hash table (could cause resource problems by reading 1000 files)
  • Perform an update like the code snippet above if an update is detected
  1. Is the code snippet above the best way to import images or are there better ones?

Hope everythink is clear and i am happy if you can confirm my solution or even better, suggest a better one.

Thank you!