According to the PHP documentation, ProductVariationStorage::loadFromContext always returns a ProductVariationInterface, it returns the variation requested in the URL if possible and falls back to the product default variation if none is found or accessible.
According to the PHP documentation Product::getDefaultVariation may return NULL, so it would be logical to update ProductVariationStorage::loadFromContext to also allow a NULL return and adapt CommerceProductThemeHooks::preprocessCommerceProductVariation accordingly.
Issue fork commerce-3579667
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
aerzas commentedComment #4
jsacksick commentedThe updated comment is incorrect, loadFromContext() doesn't necessarily load the default variation.
The default variation is the fallback, but if there is a "?v" query parameter present, it'll return the corresponding variation.
Also I think:
can be changed to:
Comment #6
tbkot commentedThe MR is updated.
Comment #8
jsacksick commented