Skip to content

2.3.0 Unable to import products with remote images (CatalogImportExport) #21881

Closed
@intd

Description

@intd

Preconditions (*)

  1. Magento 2.3.0
  2. PHP 7.2

Steps to reproduce (*)

  1. Import products (csv file with remote images)

Expected result (*)

  1. 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

if (preg_match('/\bhttps?:\/\//i', $fileName, $matches)) {

   $isUrl = false;
   if (preg_match('/\bhttps?:\/\//i', $fileName, $matches)) {
    $isUrl = true;

$filePath = $this->_directory->getRelativePath($filePath . $fileName);

  $imagePath = $isUrl ? $filePath  : $filePath . $fileName;
  $filePath = $this->_directory->getRelativePath($imagePath);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: Format is validGate 1 Passed. Automatic verification of issue format passed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions