Skip to content
This repository has been archived by the owner on Apr 29, 2019. It is now read-only.

Image attribute type import issue #42

Closed
piotrekkaminski opened this issue Nov 6, 2017 · 12 comments
Closed

Image attribute type import issue #42

piotrekkaminski opened this issue Nov 6, 2017 · 12 comments

Comments

@piotrekkaminski
Copy link
Contributor

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
Copy link
Contributor Author

From @EnricoB3 on April 13, 2017 14:11

Same issue. The image is imported as text.

@piotrekkaminski
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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:

  • Preconditions: Magento version

@piotrekkaminski
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor

Hello @piotrekkaminski,
Any news on this issue?

VincentMarmiesse added a commit to VincentMarmiesse/import-export-improvements that referenced this issue Jan 4, 2018
dmanners added a commit to VincentMarmiesse/import-export-improvements that referenced this issue Jan 16, 2018
dmanners added a commit to VincentMarmiesse/import-export-improvements that referenced this issue Jan 16, 2018
…tually use the database to load the image information
dmanners added a commit to VincentMarmiesse/import-export-improvements that referenced this issue Jan 16, 2018
dmanners added a commit to VincentMarmiesse/import-export-improvements that referenced this issue Jan 24, 2018
magento-team pushed a commit that referenced this issue Jan 25, 2018
 - Merge Pull Request #94 from VincentMarmiesse/magento2:42-imageskeys
 - Merged commits:
   1. 8d3a237
   2. 100e123
   3. 36a053f
   4. 2bbf5e0
   5. c52ad59
magento-team added a commit that referenced this issue Jan 25, 2018
Accepted Public Pull Requests:
 - magento/magento2#13339: In checkout->multishipping-> new addres clean region when select country without dropdown for states (by @enriquei4)
 - #94: #42 - Dynamically fill the image keys (by @VincentMarmiesse)


Fixed GitHub Issues:
 - magento/magento2#8621: M2.1 Multishipping Checkout step New Address - Old State is saved when country is changed (reported by @ajaysinghrana23) has been fixed in magento/magento2#13339 by @enriquei4 in 2.3-develop branch
   Related commits:
@dmanners
Copy link
Contributor

This has been fixed in 2.3-develop as part of the PR #94

@sashas777
Copy link
Contributor

Hi guys,

I made composer module based on a solution at #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

magento-engcom-team pushed a commit that referenced this issue Aug 27, 2018
MAGETWO-66666: Adding a product to cart from category page with an ex…
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants