magento-engcom / import-export-improvements

Open Software License 3.0
31 stars 29 forks source link

Image attribute type import issue #42

Closed piotrekkaminski closed 6 years ago

piotrekkaminski commented 7 years ago

From @jroca22 on April 7, 2017 19:58

I've created a custom image attribute and added to my attribute set as image. The thing is that when you try to import the attribute the same way you import images vis csv it only writes the value as text.

Preconditions

Magento 2.2.0

Steps to reproduce

  1. Create a custom image attribute and add it to your attribute set (new_image)
  2. Go to any product of that attribute set and assign the attribute to any image
  3. Export that product it and see the value of the new_image attribute on additional attributes
  4. Now let's say you want import a new image and assign to that image the new_image attribute. Let's say the image name is image01.jpg and it has been uploaded to pub/media/import
  5. On the csv change the value of new_image=image01.jpg and add image01.jpg to additional images.
  6. Import the csv and set the path to /pub/media/import

Expected result

  1. Now if you export the same product the value should be new_image=/i/m/image01.jpg. You expect Magento to copy the image to the product media folder.

Actual result

  1. Actually the attribute value is new_image=image01.jpg if you export the product again

Why is this attributed not treated the same way an image attribute created by the system?

Copied from original issue: magento/magento2#9171

piotrekkaminski commented 7 years ago

From @EnricoB3 on April 13, 2017 14:11

Same issue. The image is imported as text.

piotrekkaminski commented 7 years ago

From @jroca22 on May 8, 2017 20:32

Ciao EnricoB3, I've just imported this field with the full final path to image. This attribute value is a string so I did this workaround. If you find any other solution please share. Regrds,

piotrekkaminski commented 7 years ago

From @mukdam on May 9, 2017 9:27

I have the same error. Create an attribute which "Catalog Input Type for Store Owner" media images. When I add addtional_attributes assign value but not import

piotrekkaminski commented 7 years ago

From @amaddatu on August 2, 2017 16:13

I have experienced a very similar issue. I have had to make a workaround. I overwrote the import class at \Magento\CatalogImportExport\Model\Import\Product with my own class preference in a module. I added a new constructor that calls the function below. My new image attribute was 'some_new_image'. I hope this helps someone out there.

function _initImageArrayKeys(){ $this->_imagesArrayKeys = ['image', 'small_image', 'thumbnail', 'swatch_image', 'some_new_image', '_media_image']; }

My guess is that the protected variable _imagesArrayKeys should actually be pulling from image types data instead of hardcoded arrays.

piotrekkaminski commented 7 years ago

From @okorshenko on September 7, 2017 20:22

@jroca22 thank you for your report. Please use the issue reporting guidelines to report an issue. Include the preconditions, the steps required to reproduce, the actual result, and the expected result. Please, add the following information:

piotrekkaminski commented 7 years ago

From @magento-engcom-team on October 12, 2017 8:30

@jroca22, thank you for your report. We've created internal ticket(s) MAGETWO-81719 to track progress on the issue.

piotrekkaminski commented 7 years ago

From @NormAtHuemor on October 16, 2017 13:41

Hi, @amaddatu . Would you mind going into further detail on how you implemented the override of the import class constructor? I've set up an override in an extension based on your comment above. However, during the compile process I receive the following error:

Errors during compilation: Vendor\Extension\Model\Import\Product Missed required argument eventManager in parent::__construct call.

piotrekkaminski commented 7 years ago

From @amaddatu on October 22, 2017 9:27

@NormAtHuemor I wouldn't mind at all. Here are my Module Files In the di.xml I created a class preference for my override /etc/di.xml

I made sure that the Magento_CatalogImportExport module was loaded before my module would override. /etc/module.xml

Added my new init function in Product.php and created a new constructor override here. The constructor is nearly an exact copy of the one inside of the original class. The Imports at the top of the file were also copied from the original class. What I did add was the init function call as I stated previously that would overwrite the object's variable. /Model/Import/Product.php

function _initImageArrayKeys(){ $this->_imagesArrayKeys = ['image', 'small_image', 'thumbnail', 'swatch_image', 'some_new_image', '_media_image']; }

You can see my files below. ImageImportWorkaround(VendorAgnostic)2.zip

piotrekkaminski commented 7 years ago

From @amaddatu on October 22, 2017 9:46

Also, I have confirmed that the issue does exist in my Magento version 2.1.8, and that my workaround is for that version, however, it may work in others.

Magento ver. 2.1.8

VincentMarmiesse commented 6 years ago

Hello @piotrekkaminski, Any news on this issue?

dmanners commented 6 years ago

This has been fixed in 2.3-develop as part of the PR https://github.com/magento-engcom/import-export-improvements/pull/94

sashas777 commented 6 years ago

Hi guys,

I made composer module based on a solution at https://github.com/magento-engcom/import-export-improvements/pull/94/ and it seems works for our store. It is only for the version from 2.2.4 and less than 2.3 where the assumption that it would be fixed in the 2.3.0 release. If it won't be then I will update composer dependencies.

Feel free to use it it would help your stores: https://github.com/sashas777/magento224-issue9171