-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 issue productlist image not shown when child product image empty … #3397
fix issue productlist image not shown when child product image empty … #3397
Conversation
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.
Cool! Please just update the changelog
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.
Hey @ngongoll !
Thanks for this fix, I have some suggestions and question regarding childHasImage method :)
export function childHasImage (children) { | ||
let hasImage = false; | ||
children.forEach((child) => { | ||
if (child.image.length == 0 || child.image === 'no_selection') hasImage = true |
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'm not sure I get this right - could you explain to me why a child has an image if its images have no length or if the image is no_selection
? Shouldn't that be the opposite conditions?
also please concider to use includes
instead of forEach
and provide a default value for children, because with the wrong argument we could have an error here. If you'd add unit tests for this helper method I'd be really grateful :)
let configurableAttributes = product.configurable_options.map(option => option.attribute_code) | ||
configurableChildrenImages = product.configurable_children.map(child => | ||
({ | ||
'src': getThumbnailPath(child.image, config.products.gallery.width, config.products.gallery.height), | ||
'src': getThumbnailPath(((child.image === '' || child.image === 'no_selection') ? product.image : child.image), config.products.gallery.width, config.products.gallery.height), |
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.
we could use childHasImage here passing child as array
@@ -567,11 +567,11 @@ export function attributeImages (product) { | |||
|
|||
export function configurableChildrenImages (product) { | |||
let configurableChildrenImages = [] | |||
if (product.configurable_children && product.configurable_children.length > 0) { | |||
if (product.configurable_children && product.configurable_children.length > 0 && this.childHasImage(product.configurable_children)) { |
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.
if childHasImage method would have default value then here it could only look like this
if (product.configurable_children && product.configurable_children.length > 0 && this.childHasImage(product.configurable_children)) { | |
if (childHasImage(product.configurable_children)) { |
@ngongoll can you please introduce the requested changes in order to merge this PR? |
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.
@pkarw, please recheck
Looks fine! |
Magento1 with configuable products. If child/variant product don't have a image the product doesn't have a image in category view when category is selected from menu. Add fallback condition for value === 'no_selection'