-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Comments
@itsabe, thank you for your report. |
Hi @agorbulin. Thank you for working on this issue.
|
Hi @agorbulin , was there any update on this? |
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. |
Hi @erfanimani |
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. |
@pemann I'm just thinking, there are four situations:
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. |
Added PR here: #21146 |
@agorbulin |
Hello. |
Yes, this is still an issue |
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. |
@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. |
Hi @itsabe. Thank you for your report.
The fix will be available with the upcoming 2.4.2 release. |
These commits aren't in the 2.4.3 release? The replace function is completly missing somehow? |
This fix only prevents duplicate images, but does not help with removing images that are no longer present in the import file:
Before fix After fix 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 |
Preconditions
Steps to reproduce
Expected result
Actual result
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?
The text was updated successfully, but these errors were encountered: