-
-
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
Display variant image in cart #2336
Conversation
if ($this->images->isEmpty()) { | ||
$image = $this->getProduct()->getImage(); | ||
} else { | ||
$image = $this->images->first(); |
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 think you can just return here: return $this->images->first();
. It will return null in case there is no image.
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.
Yep but I would miss the fallback to the product image. Do you prefer to move the fallback logic elsewhere?
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.
No, I mean just remove else clause and simply return, cause if the first condition is false, it will always return it anyway. :) Like this:
if ($this->images->isEmpty()) {
return $this->getProduct()->getImage();
}
return $this->images->first();
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 didn't get you right ;) Thanks for feedback, this is fixed now.
…one found. Addresses issue #2332.
@pjedrzejewski @Arn0d Sounds good for me 👍 |
@pjedrzejewski Feedback? |
Any feedback on this @pjedrzejewski ? |
Display variant image in cart
Perfect, thank you Matthieu! 👍 |
Display variant image in cart
This PR aims to display variant image instead of product master variant image in cart. In case no variant image is available, it displays product master variant image.