Closed
Description
Preconditions (*)
- Magento 2.3.0
- PHP 7.2
Steps to reproduce (*)
- Import products (csv file with remote images)
Expected result (*)
- The product has been imported into the store
Actual result (*)
1.Error: Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in row(s):
Note (*)
The import only works from a local folder ( e.g. var/import).
Image link:
https://example.com/image.jpg
exception.log
main.CRITICAL: File 'pub/media/import/image.jpgimage.jpg' was not found or has read restriction.
The file image.jpg has been downloaded by Magento properly and it's in the directory 'pub/media/import/image.jpg'
I was able to import the products by this workaround checking if the image comes from a local or remote
$isUrl = false;
if (preg_match('/\bhttps?:\/\//i', $fileName, $matches)) {
$isUrl = true;
$imagePath = $isUrl ? $filePath : $filePath . $fileName;
$filePath = $this->_directory->getRelativePath($imagePath);