3

I'm not sure that this is a bug, as it's intentional from the looks of it, but ...

I'm working on a migration from Zencart and the original site's media folder has been downloaded and we've written a custom importer.

The feedback from the product importer is very generic, but it turns out that the original media including a space in it's filename is an issue.

Specifically, the PATH_REGEXP within \Magento\CatalogImportExport\Model\Import\Product\Validator\Media.php doesn't allow for this.

Is there any reason for this restriction? Is this due to how different file systems may interpret special characters? If I alter the REGEX to allow for spaces, Magento2 parses the file successfully, and actually changes the filename to a more comfortable format (underscores instead of spaces)

Steps to reproduce

  1. Create product import
  2. Ensure image reference within base_image, small_image or thumbnail_image contains a space
  3. Place files within pub/media/images/

Expected result

  1. Media images pass validation

Actual result

  1. Media Images do not pass validation

  2. Wrong URL/path used for attribute image in row(s): 2, 3, 4, 5, 6, 7, 8, 10, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49

  3. Wrong URL/path used for attribute small_image in row(s): 2, 3, 4, 5, 6, 7, 8, 10, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49
  4. Wrong URL/path used for attribute thumbnail in row(s): 2, 3, 4, 5, 6, 7, 8, 10, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49
  • You have to keep all images inside pub/media/import folder. – Rakesh Jesadiya Apr 24 '17 at 10:09
  • mageplaza.com/kb/… – Ankit Shah Apr 24 '17 at 10:13
  • Thanks both, but that doesn't really answer my query - I know what the issue is, but I'm wanting to know IF it should be like that? – Douglas Radburn Apr 24 '17 at 13:57
  • Did you find some side effects to this REGEXP update ? – Franck Garnier Oct 9 '17 at 14:10
  • Not yet @FranckGarnier – Douglas Radburn Oct 9 '17 at 14:26
0

I've also recently encountered this on M2.2.2

After some investigation, I personally believe this is a feature as opposed to a bug as the Magento team appear validating image names as web safe i.e. no spaces or special characters.

Historically when working with M1.x (little/no image name validation) I spent many hours fixing images when clients tried to upload images which were not web safe, so I'm welcoming this validation with open arms.

  • 1
    Shame they don't filter it when they copy it to the right path (since the original is never used outside of the import) - rather than rejecting. If they have rules, impose them internally. – Douglas Radburn Jan 11 '18 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.