I've got a custom script to import products by XML, which is ported over from v1.9 (so it is tried and tested on that version and now updated to v2.1 standards).
These are sent via a POST request, stored locally then processed one by one.
It all works fine, except for when images are involved.
Images are hosted externally and downloaded locally before processing - this download takes milliseconds and saves to the filesystem with no problems.
They are associated with the product with this snippet:
$imageFile = '/local/path/to/image.jpg'; $locations = array('image', 'small_image', 'thumbnail'); $product->addImageToMediaGallery( $imageFile, $locations, false, false );
I also set the batch processing flags to tell it it is part of a batch and not to index immediately:
Then save it:
Whenever I send a product which does not contain images, this all completes in less than a second (along with all of the variables and attributes etc.
Passing an image can cause it to slow down dramatically - to around 7 seconds per image (e.g. 4 images will take 30 seconds for the entire product creation).
I have tried this in developer mode and production mode and with both GD and ImageMagick (GD fared better) and am now at a loss as to what Magento is doing relating to the images.
Your help would be greatly appreciated!
Solved! Go to Solution.
The problem can be related to filesystem performance.
I experienced very slow product save when it contained a bunch of images when my media was hosted on external multiAZ AWS EFS.
Is your pub/media located on an external mounted drive?
Yes, it was exactly that - the pub/media directory was located on an external network share.
We eventually moved this onto an internal drive to fix this (and a few other related) performance issues.
Hi , thank you for sharing this info. We are experiencing something quite similar.
May I ask what is the final time that you get for this process, after the changes ?
I don't recall a specific figure, but it was significant - and would be even more significant if the media was moved onto an SSD.