
I have a product with LB (layout builder) enabled.
I am displaying variation fields in LB.
If the current product has no variations entity, then I get this error.
How to reproduce:
- Install Drupal + Drupal Commerce latest version.
- Set up currency, shop (everything is as usual).
- Enable Layout Builder module.
- Then enable use Layout Builder for the product here: /admin/commerce/config/product-types/default/edit/display
- Go to /admin/commerce/config/product-types/default/edit/display/default/layout
- Add any variation field, for example sku and save.
- Add the product as usual, just don't add any variations.
- Go to product view.
We get the error:
The website encountered an unexpected error. Please try again later.
Drupal\Component\Plugin\Exception\MissingValueContextException: Required contexts without a value: entity in Drupal\Core\Plugin\Context\ContextHandler->applyContextMapping() (line 155 of /var/www/html.original/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php).
I tested it here:
https://stm5fc681c8b4fb0-y1p1icurbntrmzm525uouv0uokap3bi0.tugboat.qa/pro...
Issue fork commerce-3185884
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:
- 3185884-null-context-check
changes, plain diff MR !39 merged
- 3185884-layout-builder-for
changes, plain diff MR !35 merge error
Comments
Toggle MR activity (2 comments)Comment #2
andypostComment #3
lukasss CreditAttribution: lukasss as a volunteer commentedComment #4
lukasss CreditAttribution: lukasss as a volunteer commentedComment #5
andypostComment #6
junaidpvFacing same error.
Comment #7
jsacksick CreditAttribution: jsacksick at Centarro commentedLooks like a duplicate of #3180541: Product Variation is without context in view based listing of Products when using Layout builder for managing product display ?
Could you check if the other issue is similar? It has patches, if that is the case, then we should close this one.
Comment #8
lukasss CreditAttribution: lukasss as a volunteer commented@jsacksick I think that other problem. These patches not working for this problem.
Comment #11
batkorNeed add tests for check new method
Comment #12
batkorNice. Worked :-)
Comment #13
batkorFail :-( not work in layoutBuilder preview
added 1 commit
Compare with previous version
Comment #14
batkorAfter checks, i think a this patch a bad resolve.
Need a cardinally another resolve for skip variation field blocks
Comment #16
mglamanThis does not seem related to #3180541: Product Variation is without context in view based listing of Products when using Layout builder for managing product display . The problem is FieldBlock has a requirement on the entity context. So we should make sure there is always something, even if a new stub.
added 1 commit
Compare with previous version
Comment #18
mglamanMR!39 for 3185884-null-context-check fixes this. If the default variation is NULL, we just stub an empty value.
Comment #19
batkorNice!
Thanks
Comment #20
batkorWorked
Drupal 9.1.7
DC 2.24
Comment #22
jsacksick CreditAttribution: jsacksick at Centarro commentedCommitted!