Problem/Motivation
Drupal 8.7 marked Layout Builder as a stable module. We need to ensure there is a proper integration with products which allows embedding variation fields and that field injection still properly works.
Remaining tasks
Add a context to ensure a product's default variation is present with a productPrice field items need to generate sample dataTest placement of variation fieldsPlaceholder for the add to cart form when a product ID is unavailable (default layout edit)- Test add to cart and field replacement
Test variation field injection with LB installed but not enabled- Test customizing a non-default view display mode (ie: teaser, catalog, etc custom)
Original summary
I have tried the layout builder in a fresh installation with core8.5.0 and latest dev version of commerce. I can see its a great step forward to layout the page but with problem for now.
1: With the layout builder enable, I am keep getting the error log message when I adjusting the commerce product :
Drupal\Component\Plugin\Exception\ContextException: Required contexts without a value: entity. in Drupal\Core\Plugin\Context\ContextHandler->applyContextMapping() (line 96 of /home/dpapercom/public_html/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php).
and eventually the commerce product page is completely dead, whenever click on the product link to its page, its shows a ""The website encountered an unexpected error. Please try again later."" message, until I disable the layout builder, it live again.
2: with the layout builder it doesn't display the product variation image on the product page. after I disable the layout builder, the image will come back ( I have a image_field in the product variation type )
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #107 | LayOut.pdf | 539.43 KB | londova |
| #105 | layoutbuilder products.png | 76.13 KB | neograph734 |
| #100 | 2952529-100.patch | 29.27 KB | mglaman |
| #99 | 2952529-99.patch | 29.26 KB | mglaman |
| #99 | interdiff-2952529-98-99.txt | 3.01 KB | mglaman |
Comments
Comment #2
mglamanLayout Builder is experimental. Core doesn't provide an easy way to support embedded field injection, like ours. I have ideas, and we'll be syncing on this at DrupalCon Nashville.
Comment #3
dravenkI don't understand why the layout build page calls the addToCartForm method, resulting in the empty product_id passed in. If the product_id is empty, it means that you don't need to add it to shopping cart.
Comment #4
mglamanI forgot about this issue! I have it working w/ LB in https://github.com/drupalcommerce/commerce/pull/854. This patch fixes main error, but my patch gives full support.
Changing the issue around. If an experimental module causes an error, I won't consider it a bug -- because it's experimental. Instead it is a feature request to support it.
#3 provides crash fix. My PR adds full support (adding variation fields.)
See https://twitter.com/nmdmatt/status/986002696401436675 for screenshots
Comment #5
dravenkI think since product_id is empty, it should be returned. Because using an empty product_id as a conditional query is not logical and wasteful. there's still misinformation..Do you agree?

Comment #6
dravenkContains the pull request mentioned in #4 and fix #5 error messages.
Comment #7
mglamanThanks for rolling in my patch.
We should better handle this, as it causes LB to prevent the add to cart field block from being removed.
There's an LB issue to fix that (blocks with no content) but we should consider what to do here as well.
I'll be working on the final touches for this patch.
Comment #8
steinmb commented@mglaman are you still working on this patch?
Comment #9
mglamanI can pick it back up, time got away from me. The patch works "as is" but just is not ready for being committed. Also, per #7 we need to see if core handling blocks with no content.
Comment #10
mglamanI want to see if we can improve this with the latest NumberFormatter fixes. It is overkill to load ALL the currencies (okay, it may only be one or two). But if we could just pass `USD` by default, that would look simpler.
We should be loading the default variation from variation storage. That is what filters out inactive or otherwise removed variations from the context.
In no way can we assume the variation has the same bundle as the product.
This needs to be tested.
Comment #11
lawxen commentedThe drupal8.6's
layout builderfield_layout dosn't take effect on commerce_product's form displayComment #12
lawxen commentedComment #13
pavelculacov commentedThis patch help me, but after clear cache i have error
Drupal\Core\Entity\EntityStorageException: Missing entity bundle. The "cakes" bundle does not exist in Drupal\Core\Entity\ContentEntityStorageBase->createWithSampleValues()
After debug "createWithSampleValues"
var_dump($bundle);
var_dump($this->entityTypeId);
var_dump($this->entityManager->getBundleInfo($this->entityTypeId));
My product type bundle is not equal with product variant type bundle
Comment #14
andyg5000This patch also appears to have caused the follow error on existing layouts
Comment #15
pavelculacov commentedOwn fix is
Comment #16
mglamanComment #17
mindaugasd commentedComment #18
mglamanPicking this up on Monday.
Comment #19
mglamanPer #15 the problem was mentioned in #10:
The problem with Layout Builder is that we have two ways to edit a layout:
* Customizing a product's individual layout, where we have context of data
* Managing the default layout (admin/commerce/config/product-types/simple/edit/display/default/layout) where we have no data
We should be loading the variation type from the product type's config.
Comment #20
mglamanOkay, here is an updated patch which fixes our context delivery so that variation fields show up. This can be manually tested.
Next steps:
* test coverage
* fallback display for add to cart formatter
Comment #21
mglamanEDIT: I broke the form somehow. This comment is completely null and void.
----
When manually testing, an error occurs when trying to save a variation field into section
The problem occurs in \Drupal\layout_builder\SectionComponent::getPlugin.
There is no context mapping passed
applyContextMapping(ContextAwarePluginInterface $plugin, $contexts, $mappings = [])---
We need to get the mapping defined.
\Drupal\layout_builder\Form\ConfigureBlockFormBase::submitFormhas the followingIn
\Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplaythe context mapping is always passed. EDIT this seems to only run when LB is first turned on.For variation fields we need to try and alter the context mapping to pull from the proper context definition.
--
Digging more. In
\Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait::addContextAssignmentElementthe context mapping gets set to a value element. if there were multiple satisfifying contexts, then one could be chosen. For some reason this isn't working for our embedded entities.Comment #22
mglamanIt is working! Now it is ready for the tests and fallback identified in #20
Pink boxes are the added variation fields.
Comment #24
mglamanThis is blocked on a problem when there is no existing product data. See #3054492: Allow content entity storages to define forbidden keys when generating sample entity values
Here is a new patch to fix failures on the translation routes. Also the beginnings of tests, which highlight the blocker failure.
Comment #27
mglamanCrediting tim.plunkett for the Slack support and guidance for core issues
Comment #28
mglamanThis attempts to fix some problems. But I found more. Generating variations is missing the bundle for the variations.
The
variationsentity reference is invoked for\Drupal\Core\Field\FieldItemList::generateSampleItems.But \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::generateSampleValue is dying. It fails when there are no bundles specified
The bundle is just "0" when passed.
But we define the bundle in commerce_product_add_variations_field for the FieldConfig.
Our default config is correct field.field.commerce_product.default.variations.yml
Comment #29
mglaman🤔I looks like this core function is always returning the key and not the values.
\Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::getRandomBundle
That's because of our field definition being incorrect
We have
when it should be
Comment #30
mglamanThis changes the field information. Also prevents the product context from generating variations. We'll see where this goes.
TBD: Should this spin out into its own issue? It's a general bug.
With tests passing and the field config identified as the main issue, do we need these?
Still to be worked.
Comment #31
mglamanOkay, the tests pass. Here is a patch which removes the create sample method calls with null values to see if the original reasoning behind #3054492: Allow content entity storages to define forbidden keys when generating sample entity values is moot.
I also had random failures locally. This change ensures the Add Block link is in the viewport.
Comment #32
mglamanComment #33
mglamanComment #34
mglamanLinking to #3027653: Allow block and layout plugins to determine if they are being previewed in regards to our add to cart formatter.
Comment #35
mglamanThis was breaking variation field injection for product types without layout builder enabled.
We're missing test coverage to ensure field injection works with LB installed but not enabled.
The new check should probably involved
Comment #36
mglamanThis patch
* Adds a preview fallback for the formatter if the product has been flagged as "in_preview".
* Fixes variation field injection when LB installed but not used
All that remains is now testing field injection over AJAX with the add to cart form.
Comment #37
mglamanI've added a test for overriding the default layout on a product. Locally it is erroring but I need to hit the pause button. Seeing if DrupalCI has different results.
Comment #39
mglamanNew tests. New problems.
* Overrides for the layout won't save in the tests
* Field replacement is broken due to missing CSS classes from variation fields added via field blocks.
---
Field replacement. We will need a custom block to extend \Drupal\layout_builder\Plugin\Block\FieldBlock and ensure all variation fields use our custom block class.
We'll need to override \Drupal\layout_builder\Plugin\Block\FieldBlock::build. We'll basically have to replace its logic a call to \Drupal\commerce_product\ProductVariationFieldRenderer::renderField.
Comment #40
andypostThanks for pointing different processing for empty fields, looks it needs core issue to document at least... It helps in #3055574: Empty field for Drupal core Layout builder (layout_builder)
Comment #42
mglamanCheckpoint. This adds VariationFieldBlock for variations to use our renderer.
Comment #44
pavelculacov commentedD 8.7
Comment #45
mglaman@Regnoy in which builder context did this happen? When managing the default layout or an override for a project? When adding a block? When viewing the layout editor?
Comment #46
pavelculacov commentedBefore your patch i use from comment #6
Now i have error, Can help me to remove programmaticaly
"layout_builder_product_variation_context:commerce_product_variation" from already saved Commerce Product Type
Comment #47
mglaman@Regnoy I cannot assist you without more details as I requested in #45, the context is required for product variation fields and I don't know how to replicate your error without those details.
Comment #48
pavelculacov commented@mglaman Thanks for response.
If somebody use patch #6 before and then #42
Just add in commerce > commerce_product.services.yml with your class ProductVariationContext
And remove block from layout builder, and after thant remove this services from yml. This help me
Comment #49
steinmb commentedI have time to put the patch through some manual testing. But before I test it, #42 failed. Do we need tests to pass first?
Comment #50
mglaman@steinmb it can be tested to find bugs. The noticeable failure from #42 is that fields are not replaced.
Comment #51
christian.wiedemann commentedI tested it manually with some product types.
Got following error when:
Comment #52
mglaman@Christian.wiedemann thanks for the report! This was in the default layout builder config mode on the admin side, then, for teasers?
Comment #53
christian.wiedemann commentedYes in config mode (admin/commerce/config/product-types/suit/edit/display/teaser/layout). I just want to render a product list with "view mode" teaser. And I manage the teaser with layout builder.
Comment #54
mglamanThanks! I have not yet tried to manage anything but the default display; I didn't expect this problem :/ good findings!
Comment #55
christian.wiedemann commentedGot following error:
AssertionError: assert($context instanceof ProductInterface) in assert() (line 80 of modules/contrib/commerce/modules/product/src/ContextProvider/ProductVariationContext.php).
assert(, 'assert($context instanceof ProductInterface)') (Line: 80)
Drupal\commerce_product\ContextProvider\ProductVariationContext->getRuntimeContexts(Array) (Line: 102)
Drupal\commerce_product\ContextProvider\ProductVariationContext->getAvailableContexts() (Line: 97)
Drupal\Core\Plugin\Context\LazyContextRepository->getAvailableContexts() (Line: 44)
Drupal\layout_builder\Element\LayoutBuilder->getAvailableContexts(Object) (Line: 265)
Steps to reproduce:
A quick fix is:
But not sure if this works.
Comment #56
mglamanSo you're getting the error on a node layout form? This hasn't been tested against nodes. Can you provide more details on your node setup? This has only been tested on configuring the product entity view display.
Comment #57
ctrladelNote that core versions previous to 8.7.2 will need this patch https://www.drupal.org/project/drupal/issues/3053529 to enable the "Allow each product to have its layout customized." option on products.
Comment #58
christian.wiedemann commentedyes the error occurs when I use the layout builder for a "singel customaized node". Layoutbuilder still works when I use Layout Builder for the node type.
Comment #59
ctrladelRan into the assertion exception on node edit as well, here's a patch that changes it to an if statement like in #55. This does allow the value to be null when the context is returned but that seems okay based on what other getRuntimeContexts() implementations are doing.
Comment #60
ajitsTo trigger the test bot. I see a couple of tabs instead of spaces in the code though (interdiff file line 85 and 86).
Comment #62
pavelculacov commentedLast Patch Not working with this issue last patch
EntityViewBuilder::viewField() does not respect entity current language when used with an entity reference field
Is working only with this compatibility
1) "Support for Layout Builder module" : "https://www.drupal.org/files/issues/2019-05-20/2952529-42.patch"
2) "EntityViewBuilder::viewField() does not respect entity current language when used with an entity reference field" : "https://www.drupal.org/files/issues/2019-05-03/entity-view-builder-entit..."
Comment #63
morbus iff#59 (without the patch from #2955392: EntityViewBuilder::viewField() does not respect entity current language when used with an entity reference field) is working pretty good for me so far, with some slight concerns:
Comment #64
morbus iffAssuming:
* a product's default entity_view_display is customized with Layout Builder
* and that layout contains product variant fields
Then:
* Viewing a product without any product variations
** For example, creating a product and hitting "Save" instead of "Save and add variations"
Causes the following error:
The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Component\Plugin\Exception\MissingValueContextException</em>: Required contexts without a value: entity in <em class="placeholder">Drupal\Core\Plugin\Context\ContextHandler->applyContextMapping()</em> (line <em class="placeholder">155</em> of <em class="placeholder">core/lib/Drupal/Core/Plugin/Context/ContextHandler.php</em>). <pre class="backtrace">Drupal\layout_builder\SectionComponent->getPlugin(Array) (Line: 69)Comment #65
morbus iffAnother small hiccup, and this requires some setup.
* Create product type A and product type B.
* On product type A, create a Reference field to product type B. Call it "Similar Products".
* Create three product type B products.
* Create one product type A product that references all three product type Bs.
* For product type B, Manage Display and choose Layout Builder.
* Add the product title field.
* Add the variation price field.
* For product type A, Manage Display, and choose Layout Builder.
* Add the "Similar Products" Reference field you created above, with Formatter "Rendered entity".
* View your product type A product.
* For the "Similar Items" Reference render:
** You should see the correct product B entity titles.
** But you'll see the product A price instead of the product B price.
** Any other variation field from B will be replaced with A's version instead.
Now:
* Head back to product type B, Manage Display, unchoose Layout Builder.
* Add the product title field.
* Add the variation price field.
* View your product type A product.
* The product type B References should be correct now.
Comment #66
morbus iffAnd another:
# Create a product type with "Inject product variation fields into the rendered product."
# Create a Color product attribute with Black, Blue, and Red. Assign it to your product type.
# Create a product of that type with three variations:
## Each product variation should have a different price.
## Each product variation should have a different attribute.
# For your product type's "Manage display", use Layout Builder and display SKU, Price, and Variations.
## For the SKU and Price fields, set the Label to "Hidden".
# Load the product.
On initial product page load, you should see the first variation's SKU (without a field label) and Price (without a field label). Great. Upon selecting a different variation though, the AJAX load occurs, and you should see the Price change to the new variation's price. However, a) this new price is displayed with the "Price: " field label, and b) the SKU field does not change. You're now seeing the second variation's (AJAX-loaded) price with the first variation's (initial page-loaded) SKU.
The cause appears to be because the AJAX will load only the configuration from the "Manage Display" of the product variation, NOT any of the configuration from the "Manage Display" Layout Builder of the product. By default, a product variation's "Manage Display" does not display SKU, so that's never returned in the AJAX and thus is never updated in the rendered Layout Builder product. Similarly, a product variation's default "Manage Display" displays "Price" with the Label, so that label is returned/shown in the AJAX, and ignores ("breaks") the product's Layout Builder render. The same occurs with custom added fields: an image added to the product variation will be returned in the AJAX based on the product variation's "Manage Display" configuration, not the product's "Manage Display" Layout Builder configuration.
One possible site-builder workaround is to ensure that your product variation's "Manage Display" is just as "perfect" as your product's "Manage Display" LB (matching displayed fields, label configuration, etc.). However, this breaks down a little bit when you use Block Class within Layout Builder to assign CSS classes to a field, which you can't do in a normal non-LB "Manage Display" (without an extra contrib module, at least).
Comment #67
michaelprflores commentedComment #68
morbus iff#59 no longer cleanly applies to 2.15. Updated patch attached, including fixes:
* removed unused (but added in #59) Drupal\Core\Url.
* spelling correction of current to currency.
* spaces/tab cleanup.
* missing doxygen added.
Comment #69
londova commentedI have a similat problem, while using Commerce with "Bootstrap Layouts" module.
The price field is not visible, while the others look OK.
Comment #70
freelockRerolled #68 for Commerce 8.x-2.16.
Comment #71
pavelculacov commented+1 Working
Comment #72
mglaman😬 forgot to remove myself. I'm currently helping support a project which has #70. Hopefully I can use this as a chance to land this issue for the next release.
Comment #73
londova commentedSounds great. I am also waiting to get it published.
Comment #74
londova commentedIs it possible to close this issue now, so it can be implemented in the new commerce version?
Comment #75
morbus iff@Londova/#74: This issue is the primary source of getting it implemented in the next Commerce. #70 is working for me (excepting the bugs I've mentioned), under Commerce 2.16.
Comment #76
morbus iffSetting this back to "Needs work". The current patch in #70 gets us half-way there, but there's still a lot of room for improvement (at least #63, #64, #65, and #66).
Comment #77
waspper commentedI've faced following bug after applying patch in #70, by trying to add a translation to any field:
But after checking, I've seen it's just needed a small validation before trying to get variation type ID at line 65 of commerce/modules/product/src/ContextProvider/ProductVariationContext.php. So, by just loading product type, it's ok again.
Attached newer patch, with small change. Leaved as "Needs works" to allow processing pending topics.
Comment #78
batkor#70 patch worked for my.
Drupal 8.8.1
One language
Comment #79
mglamanReviewing. This will never land perfectly. I'd like to see why we have test failures and try to get this in for 2.19, then lead for follow ups.
Comment #80
mglaman😬somehow we got a patch containing a
.origfile from a failed apply?We should make this its own issue, actually. Helps reduce this patch size.
Would be great to see if Layout Builder improved at all to make this easier.
😬no wonder why the patch is so huge :/ another failed hunk file.
🤔this could be its own issue, too. To improve the route context provider.
We should spin this into its own issue as well.
😬dependency injection
🤔does this do anything if there's no Layout Builder override, even.
Comment #81
mglamanHere's a reroll of #77 with the
*.origfiles removed and the following child issues:Not sure if this one should be spun out #3145079: Provide a product variation context.
Comment #82
mglamanOops, the price field changes still merged over, even though they were committed.
Comment #84
mglamanFix of the following:
Not needed
use EntityContextDefinition to fix deprecations
Notes for self
Use isNew instead
The product type is already loaded, but maybe we should make this an earlier exit before we fetch storages and load the product type.
Comment #86
mglamanI think this fixes the tests. It was hit or miss locally, assuming that it is my local.
Comment #88
mglamanSo we're back to the same problems in #42.
Ajax field replacement for variations is not working. If you're using Cart Flyout it isn't noticeable, since replacement is done in JavaScript. But it doesn't work for our normal add to cart form.It's not working unless you allow all fields on a variation to be rendered.\Drupal\commerce_product\Plugin\Field\FieldWidget\ProductVariationWidgetBase::ajaxRefreshinvokes\Drupal\commerce_product\ProductVariationFieldRendererInterface::replaceRenderedFieldswhich uses the variation view mode. That doesn't account for the field blocks added to the product layout.For some reason,
ProductLayoutBuilderIntegrationTest::testConfiguringOverrideLayoutfails to save the override.EDIT
To fix AJAX field replacement:
\Drupal\commerce_product\ProductVariationFieldRenderer::renderFieldThat means we may need a swapped
\Drupal\commerce_product\ProductVariationFieldRendererInterface::replaceRenderedFieldsimplementation when Layout Builder is installed which doesn't try to use the variation's display config.Comment #90
mglamanSorry, this won't make 2.19.
@Morbus Iff has outlined all of the problems with missing variation field AJAX replacement in #63, #64, #65, #66.
Comment #91
neograph734I have added some child issues for allowing lay-out builder on orders. (Crosspost from #2915559-24: Display custom fields on order admin view page, but better fitting here.)
Comment #92
valicReroll of #88 with fix / implementation of ajax field replacement.
Added service provider to swap ProductVariationFieldRenderer with ProductVariationFieldRendererLayoutBuilder
which implements it's own
replaceRenderedFields, with fallback to default version (if layout builder module is on, but it's not used)Current implementation ProductVariationFieldRendererLayoutBuilder covers both default per bundle and custom per each entity layouts.
Tests should be green now.
Comment #93
valicAttaching proper interdiff, by mistake had uploaded with .patch extension on #92
Regarding #63 and long SKU, not sure what we can do there, sampling for string field item (which is sku field) is done with fetching settings
$field_definition->getSetting('max_length'), and SKU does not have limit.
#66 is covered with last patch
Comment #94
londova commentedHi,
Layout Builder is a part of Drupal core for a long time.
The fact that Commerce does NOT support all the Core functionalities is a shame for maintainers and shoud bring it back to "Beta" version.
Comment #95
tim.plunkettI think that's unfair to Commerce. I say that as the primary developer of Layout Builder.
Next week will be the 3rd anniversary of Commerce 8.x-2.0, Layout Builder was added to core well after that and has only been stable for half of that time.
Please be patient with the volunteers who maintain modules!
Comment #96
mglaman@Londova thanks for your feedback. Sorry you feel we should make an e-commerce framework beta due to a core feature which was experimental for most of our stable release cycle. If you'd like, we are always available for sponsored contribution development: https://www.centarro.io/products/centarro-support.
Here's a review. I'm pretty sure this is it. Just some code nits.
We should be passing the $view_mode, shouldn't?
This logic seems like it could just go into an override of renderFields.
then: if not layout builder, call parent. Else do logic.
We could just explode on `:` and the field name is the last entry of the array, isn't it?
Comment #97
tim.plunkett#96
1) I believe so
2) That sounds like a plan
3) Yep, this is the code used in LB:
list (, , , $field_name) = explode(static::DERIVATIVE_SEPARATOR, $plugin_id, 4);Comment #98
mglamanSo I found an interesting problem for #96.1. The view mode passed is _custom, not the original view mode. So we cannot reliable pass the view mode. Which means layout builder for non-default displays does not work. I think that can be okay, but I'd like to see if we can fix that.
Forgot to refresh before #97 😅. Will update [] = explode based on what LB does.
The original view mode is in
$this->thirdPartySettings['layout_builder']['view_mode']Comment #99
mglamanThis addresses the view mode support.
Comment #100
mglamanForgot
[]overlist()is like 7.1 or whatever.Comment #102
mglaman🥳 Boom. This solid enough for now! Anything else can be follow ups. I believe a majority use case is covered.
Thank you everyone for using the patches and providing feedback.
Comment #103
londova commentedThis update doesn’t work for "Product variation", fields like Price and SKU just disappear.
@mglaman, I agree with your statement #96, but a bit different:
1) I am happy to pay for a ready functional product (not under development);
2) The seller to offer after-sales support for a certain period, like many paid modules and themes.
If you have such options, please let me know and I'll proceed to buy.
Comment #104
londova commentedComment #105
neograph734Hi Londova, I was just playing around with this, but for me it works (commerce 8.x-2.21).
In layout builder you can choose different fields from both product (body and variations in below screenshot) and also some fields from product variations (price, SKU and images). All fields update accordingly as soon as I change an attribute.
If this does not solve your issue, could you at least provide some steps to reproduce your issue?
Comment #106
tim.plunkettThanks @Neograph734!
@Londova please open a new issue with steps to reproduce.
Comment #107
londova commentedHi Neograph734,
Please give more info about your test environment.
Here are my TEST details:
Modules: Layout Builder, Layout Discovery
Default Theme: Bartik
Installation method: admin interface
I attached a PDF file with some screenshots.
The first 3 pictues are before using Layout Buider, and all fields are OK.
when the "Layout Builder" was activated from Ptoduct Type Display screen, fields Price and SKU dissapear.
Please advise what is wrong?
Comment #108
neograph734There is really no use in enabling layout builder if you are not planning to change the layout of the page. You have to use the Manage Layout button to make changes. Just enabling layout builder indeed seems to remove these fields, but you can add them again.
As explained in my post above, I've managed to add multiple variation fields, including price and SKU, on the Manage Layout page, by choosing them from the Product variation fields section. You can use the 'Show content preview' checkbox at the top to see if they are actually there.
But please, there are 53 people subscribed to this issue, who all get an email if someone posts here. If this still does not solve your problem, create a separate issue for your support request as requested by Tim.
Comment #110
jucedogi commented@Neograph734, thank you. The method you posted at #105 helped me out greatly.
Problem I found here was that I have an image field in the product variation types. What happens here is that unless I specifically add an image, it will not appear. I had added a default image so that it would serve as a generic image to be used until a specific image was added. This default image is treated as non existent.
After adding an actual image to the field it now displays as expected as per the method shown in #105.
I mainly add this here so that if anyone else is having a hard time with this configuration they won't lose as much time as I did trying to figure out what was going on.
FYI using Drupal 8.9.7
Comment #111
lukasss commentedI 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:
Drupal\Component\Plugin\Exception\MissingValueContextException: Required contexts without a value: entity in Drupal\Core\Plugin\Context\ContextHandler->applyContextMapping() (line 155 of core/lib/Drupal/Core/Plugin/Context/ContextHandler.php).
Any ideas?
Comment #112
nevergone#111 comment is existing error. Is it related to this issue?
Comment #113
lukasss commented@nevergone I create new problem here https://www.drupal.org/project/commerce/issues/3185884
Comment #114
jsidigital commentedDoes this patch only work if you are running the dev version of commerce?
Also, has anyone tested if it works with Drupal 9 or is it only for Drupal 8.x?
Thank you for your time.
Comment #115
morbus iff@jsdigital: this patch is currently in the latest release versions of Commerce.
It does appear to work in Drupal 9.1.
Comment #116
jsidigital commentedThank you for the quick reply @Mobus Iff.
I was able to get layout builder working... somewhat.
I just do not get the "Product Variation Fields" as an option to add them to the layout.
I enabled layout builder on the Product Type.
On LB I click on "Add Block" and I only get "Variations" and "Default Variations" as options, no price, sku, etc.
Is there something I am missing?
Comment #117
jsidigital commentedOkay so I found the problem...
My problem was the following (in case it helps anyone else)...
I was adding the layout via the Layout Library:
/admin/structure/types/manage/product/layout-library/mylayout
When I should have been doing it here:
/admin/commerce/config/product-types/default/edit/display/default/layout
So I guess it is worth mentioning that the Commerce + Layout Builder integration is NOT working 100% if you try to have multiple layouts via the layout builder library (Layout Library module). It only works correctly if you use the single default layout of LB.
Thank you.
Comment #118
freelock@jsisdigital So it sounds like this issue is fixed -- Commerce is compatible with Layout Builder.
However, it's not currently compatible with Layout Builder Library. Seems like a new issue?
Comment #119
jsidigital commented@freelock That is correct. This issue is fixed and compatible with Layout Builder (I am using Drupal 9.1x) but not yet compatible with Layout Builder Library module.
It would have to be considered a new issue for those wanting to use the Layout Builder library which would apply for anyone that wants to give their editors more than one option to select different layouts per product type. If you have a product like a physical book AND a download version as well but want to display the digital and physical book differently (using the same product type), then Layout Builder Library is a must.
Currently it somewhat works. All product type fields work but none of the variation fields are appearing as options to add in the layout.
For the moment I can live with the default LB integration. That is why I didn't start a new issue.
Comment #120
lisa.rae commentedComment #121
rossidrup commentedi can confirm layout builder is not compatible with commerce....
i tried it and the image is not showing up for product variation...I dont know why
seems the same issue as 4 years ago
https://www.drupal.org/project/commerce/issues/2951841