Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image attribute type import issue #9171

Closed
jroca22 opened this issue Apr 7, 2017 · 12 comments
Closed

Image attribute type import issue #9171

jroca22 opened this issue Apr 7, 2017 · 12 comments
Labels
Component: ImportExport Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@jroca22
Copy link

jroca22 commented Apr 7, 2017

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?

@EnricoB3
Copy link

EnricoB3 commented Apr 13, 2017

Same issue. The image is imported as text.

@jroca22
Copy link
Author

jroca22 commented May 8, 2017

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,

@mukdam
Copy link

mukdam commented May 9, 2017

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

@amaddatu
Copy link

amaddatu commented Aug 2, 2017

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.

@okorshenko
Copy link
Contributor

okorshenko commented Sep 7, 2017

@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:

  • Preconditions: Magento version

@magento-engcom-team magento-engcom-team added Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update labels Sep 11, 2017
@magento-engcom-team magento-engcom-team self-assigned this Sep 18, 2017
@magento-engcom-team magento-engcom-team removed their assignment Oct 5, 2017
@magento-engcom-team magento-engcom-team added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed Progress: needs update Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Oct 5, 2017
@magento-engcom-team
Copy link
Contributor

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

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 12, 2017
@NormAtHuemor
Copy link

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.

@amaddatu
Copy link

amaddatu commented Oct 22, 2017

@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

@amaddatu
Copy link

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

@piotrekkaminski
Copy link
Contributor

This issue was moved to magento-engcom/import-export-improvements#42

@sashas777
Copy link
Contributor

Hi guys,

I made composer module based on a solution at magento-engcom/import-export-improvements#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

@jruzafa
Copy link

jruzafa commented Oct 15, 2018

Hello,

this is still happening in CE 2.2.5 I have applied a patch based on the PR I have seen in this and other threads.

https://gist.github.com/jruzafa/61183fe581a6c86b6a06682f905e42c9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: ImportExport Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

10 participants