I have a script which imports products from XML data POSTed to it from an external source into Magento 2.1.
Everything works and imports fine, however when images are added to a product, the $product->save();
command takes around 7 seconds per image uploaded.
As a whole, it can add around 50 products without images to the system in around 4 seconds.
When images are passed in the import (hosted externally), they are downloaded locally and associated with the product before saving it.
$product->addImageToMediaGallery(
$imageFile,
$locations,
false,
false
);
I have tried using both GD and ImageMagick as the processors, but I now do not believe this to be the cause of the slowdown.
Any suggestions on where to look next to find out the source of the delay?
$product->save();
call. I wondered if it was to do with resizing the image for the various image sizes, but using ImageMagick actually increased the time by 300%!