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

Images Not Replaced via CSV Import #14398

Closed
itsabe opened this issue Mar 27, 2018 · 18 comments
Closed

Images Not Replaced via CSV Import #14398

itsabe opened this issue Mar 27, 2018 · 18 comments
Assignees
Labels
Component: CatalogImportExport Fixed in 2.4.x The issue has been fixed in 2.4-develop branch 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 Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release 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 Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.

Comments

@itsabe
Copy link

itsabe commented Mar 27, 2018

Preconditions

  1. Magento 2.2.2
  2. CSV file with columns [sku], [additional_images] and one row of values
  3. Current images of sku is A, B, C, D.
  4. My CSV file contains images A, B, E, F, G

Steps to reproduce

  1. Create CSV file
  2. First column is sku with one existing sku in catalog.
  3. Second column is additional_images with comma separated values of relative path.
  4. Import file into Magento with Add/Update Import Behavior.

Expected result

  1. Images of the sku should be A, B, E, F, G. (The images I have in my CSV file).

Actual result

  1. Images of the sku are A, A, B, C, D, E, F, G. All the images got appended to the product.

I know there is a Import Behavior of Replace but that recreates the whole item. Is there a way to do so without recreating the item?

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Mar 27, 2018
@ghost ghost self-assigned this Jul 24, 2018
@ghost ghost added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development 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 Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release 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 Component: CatalogImportExport labels Jul 24, 2018
@ghost ghost removed their assignment Jul 24, 2018
@ghost
Copy link

ghost commented Jul 24, 2018

@itsabe, thank you for your report.
We've acknowledged the issue and added to our backlog.

@agorbulin agorbulin self-assigned this Nov 10, 2018
@magento-engcom-team
Copy link
Contributor

Hi @agorbulin. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@agorbulin agorbulin removed their assignment Nov 10, 2018
@erfanimani
Copy link
Contributor

Hi @agorbulin , was there any update on this?

@erfanimani
Copy link
Contributor

Product imports should be idempotent and declarative. Importing the same CSV twice should not result in unwanted side-effect, as clearly is the case now.

I do want to add that to do this properly is quite a big job and requires Magento to keep track of file metadata such as a hash of uploaded images. Then it can compare the hash with a hash of the newly uploaded file and determine whether it should delete the previous one and upload the new one, or just leave things as-is. Simply blasting away all images on import does not scale.

@agorbulin
Copy link

Hi @erfanimani
unfortunately, but I'm not investigation this issue.

@pemann
Copy link

pemann commented Feb 11, 2019

What if there were a selection between replacing all product images with the ones from csv, or adding new images but not deleting old ones? It could be easy as one more column to csv or one more checkbox to the import form.

@erfanimani
Copy link
Contributor

erfanimani commented Feb 11, 2019

@pemann I'm just thinking, there are four situations:

  1. Filename changed, image changed
  2. Filename changed, image is still the same
  3. Filename is the same, image changed
  4. Filename is the same, image is still the same

I was thinking about things like filename comparisons and hash comparisons, but I think the only option is a hash check and ignore things like filename changes because it would be too hard. There's a big downfall though, and I'm not sure if it's acceptable.

I propose the following: During the import we load the existing product and it's images. We create an array with md5 hashes. Then we create an array with md5 hashes of the images specified in the import CSV. We do a comparison, and we know which ones to leave alone and which ones to delete. One downfall of this approach is that you could rename an existing image and do another upload, but the filename in Magento will not change because the hashes have been kept the same.

I'll experiment with this at work tomorrow and maybe suggest this in a PR.

Your approach is not really ideal either @pemann because on a high volume production site you wouldn't want to blast away all images. Or maybe sites that have high volume are advised to use a third party importer... Also it would mean that if you run imports regularly, the filenames of all images would keep changing forever, and any images URLs externally referenced would stop working.

@erfanimani
Copy link
Contributor

Added PR here: #21146

@jg-development
Copy link

@agorbulin
Is there any updates on this issue?

@agorbulin
Copy link

Hello.
I do not check the issue. Is it still actual?

@template-provider
Copy link

Yes, this is still an issue

@ghost ghost added Progress: dev in progress and removed Progress: PR Created Indicates that Pull Request has been created to fix issue labels Sep 8, 2020
@engcom-Oscar
Copy link

Hi @itsabe , I have rechecked this issue on the latest 2.4-develop Magento instance. How I see, it is expected behavior when you select Products Import - Add/Update - new images are added to your product, but old ones remains there as well. It also confirmed here in documentation: https://docs.magento.com/user-guide/system/data-import.html. If your have more details of the problem, please update ticket description, otherwise this ticket is not valid and need to be closed.

@HenKun
Copy link

HenKun commented Sep 8, 2020

@engcom-Oscar Where exactly is stated that product images add up instead of being replaced? Type "Add/Update" means "Add or (if present) update products". Not "Combine old and new attribute values". At least as far as my logic goes. Furthermore there is another ticket concerning the same issue: #21885 and already a PR, but just nothing happens with this issue. I think it would be a step backwards if the (quite old) ticket is closed and everything must be started from the beginning.

@m2-community-project m2-community-project bot added Progress: PR Created Indicates that Pull Request has been created to fix issue and removed Progress: dev in progress Progress: needs update labels Sep 24, 2020
@ghost ghost unassigned engcom-Oscar Oct 8, 2020
@m2-community-project m2-community-project bot added Progress: PR Created Indicates that Pull Request has been created to fix issue and removed Progress: PR Created Indicates that Pull Request has been created to fix issue labels Oct 8, 2020
@magento-engcom-team magento-engcom-team added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Oct 13, 2020
@Cloudy777
Copy link

These commits aren't in the 2.4.3 release? The replace function is completly missing somehow?

@mfickers
Copy link
Contributor

This fix only prevents duplicate images, but does not help with removing images that are no longer present in the import file:

  1. Product in Magento has images A, B, C
  2. Row in import file has images A, D, E

Before fix
After import, product has images A, A, B, C, D, E

After fix
After import, product has images A, B, C, D, E

There are still two images attached to the product that were not present in the import file. This was part of the original bug description and is still occurring on version 2.4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: CatalogImportExport Fixed in 2.4.x The issue has been fixed in 2.4-develop branch 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 Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release 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 Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.