-
Notifications
You must be signed in to change notification settings - Fork 307
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
Fix for duplicate images that would cause multiple realtions... #483
Open
mblarsen
wants to merge
1
commit into
dweeves:master
Choose a base branch
from
mblarsen:duplicate-image
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of "multistore" setup, then this select may return all images with same name than the one you try to import.
Say : Store A , item has image2.jpg, Store B has image.jpg and you want only to import "image.jpg" for image of an item in storeA.
What will happen is that the imageid will be the same than in store B.
This is not a real bug since magento image storage allows only "unique" named images,
So "image.jpg" is guaranteed to be unique in the whole magento system and as you said, magento has trouble with "duplicate" images.
Then just add a comment above to explain this "side effect" is indeed wanted and exploits magento 1 name = 1 image reference limitation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are not intended to have multiple set of media gallery images for each store.
Although you can create that using Magmi it is kind of on borrowed time since when you go and save a product in the product view for which you didn't upload the image Magento will simply insert a new row to
catalog_product_entity_media_gallery_value
.You don't even have to be on the Images tab. It will happen no matter what. The same if you remove an image from a store view it will be removed from all store views. A product has a media gallery with same images
What you CAN do is set 'exclude' differently for each store view so that an image is excluded from some and not for others. (not now of course since the code pre this PR would create duplicates, that's later removed by Magento). See this article
So coming to think of it you might not even need to do the join with
catalog_product_entity_varchar
first. (I'll try that out).ps: when I was talking about duplicates and uniqueness it was not with regards to system wide images but only on the same product, which is where the problem is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm removing the
catalog_product_entity_varchar
check ingetImageId()
works just as well = to the same effect.Updates: I guess if you do an update a new row will be created if the image on the product doesn't exists. If it does an existing image will be used and returned as the id. Still if it is an update you won't find an image doing the join since updates to
catalog_product_entity_varchar
happens aftergetImage()
when the plugin returns theovalue
to the underlying engine, right?I forgot to mention before that I am using a multistore multiwebsite setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I tried swapping the photo of a product to another photo that already existed on the product in media gallery. This works someone fine.
The default values on the products are wrong:
Will all remain as they were before, on the old image. But on the store views these will be correctly swapped to the new image.
(As I see this is a different problem and has nothing to do with what changes I'm proposing here.)
Also magmi doesn't remove the the previous excludes essentially hiding the old small_image and thumbnail from the gallery 👍 .
But the default values should probably be addressed as well in another issue.
In the end if you update an image you end up with a bunch of small_image and thumbnails that are hidden from all stores. Doesn't do any harm but it would be nice to have them go away.
I've tried with the
media_gallery_reset
to values 0 and 1 and the column completely left out. No difference.