- 🇬🇧United Kingdom Dubs
This doesn't work for views unfortunately. The LazyContextRepository statically caches the first product variation, so in views with multiple products, the product variation will always be the first variation in the list of rendered entities, i.e. all results in the view will only show data for the first product's variation. I'm working on a fix but it may not be possible without overriding the LazyContextRepositoy.
- 🇬🇧United Kingdom Dubs
So I've overridden the context repository in commerce_product. I'm not sure if this is the best approach, but take a look and let's see if we can get this merged and working.
The patch is based of the diff from Merge request !83, with an extra service override.
- 🇬🇧United Kingdom Dubs
So I've overridden the context repository in commerce_product. I'm not sure if this is the best approach, but take a look and let's see if we can get this merged and working.
The patch is based of the diff from Merge request !83, with an extra service override.
- First commit to issue fork.
- Status changed to Needs review
almost 2 years ago 9:54am 16 March 2023 - Status changed to Needs work
almost 2 years ago 9:39am 22 March 2023 - 🇮🇱Israel jsacksick
Setting the status to "Needs work" as we really need tests coverage to ensure this doesn't break in the future again.
- Status changed to Needs review
almost 2 years ago 12:43pm 22 March 2023 - 🇺🇸United States morbus iff
#23 works for me. I've not been able to get the MR to apply.
-
jsacksick →
committed 4e2941b0 on 8.x-2.x authored by
tBKoT →
Issue #3180541 by Christian.wiedemann, tBKoT, valic, Dubs, junaidpv,...
-
jsacksick →
committed 4e2941b0 on 8.x-2.x authored by
tBKoT →
-
jsacksick →
committed f95dafd0 on 3.0.x authored by
tBKoT →
Issue #3180541 by Christian.wiedemann, tBKoT, valic, Dubs, junaidpv,...
-
jsacksick →
committed f95dafd0 on 3.0.x authored by
tBKoT →
- Status changed to Fixed
over 1 year ago 9:56am 30 March 2023 - 🇮🇱Israel jsacksick
Commited the patch from the MR, thanks everyone!! Committed.
-
jsacksick →
committed 4c5abd27 on 8.x-2.x
Revert issue #3180541.
-
jsacksick →
committed 4c5abd27 on 8.x-2.x
-
jsacksick →
committed bd19e0c9 on 3.0.x
Revert issue #3180541.
-
jsacksick →
committed bd19e0c9 on 3.0.x
- Status changed to Needs work
over 1 year ago 3:27pm 31 March 2023 - 🇮🇱Israel jsacksick
A new release including this fix was tagged yesterday (2.34) and it already introduced 2 critical issues so decided to revert it and we'll target a proper fix in 2.36 I guess.
- 🇮🇱Israel jsacksick
See 🐛 Commit of 3180541 leads to out of memory error Fixed and 🐛 Error: Call to undefined method Symfony\Component\HttpFoundation\RequestStack::getMasterRequest() Fixed for reference.
- 🇺🇦Ukraine tbkot
I’ve found one more problem with those changes. As it uses "hook_entity_prepare_view" when we try to render multiple products programmatically it adds the last one to the request attributes. As a result, we have incorrect data from variation(price, SKU, etc.) because it will be taken from the last product in the render list.
- 🇺🇦Ukraine tbkot
One more issue with the patch is that Drupal does change the already existing context. So, for example, if we going to display multiple products, even though we find a way to set the correct variation entity in the context for every product on the page, the data from the first variation will be shown for all of them.
- 🇺🇸United States morbus iff
While #23 works for me without any of the problems other folks have experienced (yet), I think I have an example of #39 too. On product A, I have a "Similar products" entity reference field, which references product B. Now, if I make a view called "Similar Products", intended to be displayed on product A, then it'll take the current entity as the argument (A), relationship load the entity from A's Similar Product field (B), then relationship load the variants from that relationship (B's variants). At this point, if I display the product variant view field "Image", then B's variant's images will be displayed (both in the View preview and on the product A entity). But, if I tweak the view from Fields display to Rendered entity, then I will see the correct B's variant's image on the View preview but, on the product A entity, the image will always show Product A's Image instead.
- Status changed to Needs review
over 1 year ago 1:26pm 12 April 2023 - Open on Drupal.org →Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7last update
about 1 year ago Not currently mergeable. - last update
about 1 year ago 780 pass, 2 fail - last update
about 1 year ago 780 pass, 2 fail - last update
about 1 year ago 780 pass, 2 fail - last update
about 1 year ago 638 pass, 67 fail - last update
about 1 year ago 638 pass, 67 fail - last update
about 1 year ago 638 pass, 67 fail - last update
about 1 year ago 780 pass, 1 fail - last update
about 1 year ago 787 pass - 🇮🇱Israel jsacksick
@tBKoT:
I’ve found one more problem with those changes. As it uses "hook_entity_prepare_view" when we try to render multiple products programmatically it adds the last one to the request attributes. As a result, we have incorrect data from variation(price, SKU, etc.) because it will be taken from the last product in the render list.
We're still using the hook_entity_prepare_view(), so I guess this comment is still valid? Because this hasn't been RTBCED yet, I'm a bit reluctant to get this in for 2.37, so we should look aim to include the fix in 2.38.
- last update
11 months ago 750 pass, 10 fail - last update
11 months ago 750 pass, 10 fail - last update
11 months ago 750 pass, 10 fail - last update
11 months ago 783 pass, 1 fail - last update
11 months ago 790 pass - 🇮🇱Israel jsacksick
@tBKoT: For the new event subscriber introduced, could we conditionally register it using a service provider instead?
Also, I wonder if we can get an RTBC here...
@Morbus Iff? @Dubs? Anyone? - last update
11 months ago 791 pass - last update
11 months ago 784 pass, 2 fail - last update
11 months ago 791 pass -
jsacksick →
committed 236335bf on 8.x-2.x authored by
tBKoT →
Issue #3180541 by tBKoT, Christian.wiedemann, valic, Dubs, junaidpv,...
-
jsacksick →
committed 236335bf on 8.x-2.x authored by
tBKoT →
-
jsacksick →
committed 2a978edf on 3.0.x authored by
tBKoT →
Issue #3180541 by tBKoT, Christian.wiedemann, valic, Dubs, junaidpv,...
-
jsacksick →
committed 2a978edf on 3.0.x authored by
tBKoT →
- Status changed to Fixed
11 months ago 12:54pm 5 February 2024 -
jsacksick →
committed 0b2a4db4 on 8.x-2.x
Issue #3180541 followup: Commit the missing event subscriber.
-
jsacksick →
committed 0b2a4db4 on 8.x-2.x
-
jsacksick →
committed 09587b41 on 3.0.x
Issue #3180541 followup: Commit the missing event subscriber.
-
jsacksick →
committed 09587b41 on 3.0.x
- 🇺🇸United States morbus iff
With this patch committed, looks like #40 is still an issue for me.
- 🇺🇦Ukraine tbkot
Hi @morbus-iff
Could you describe a bit more how I can reproduce the issue? I've tried a bunch of manipulations to catch the issue you faced with. Is it possible to add step by step on all your way to add "Similar products" on the product page? Especially the display configuration for product and variation as you use "Rendered entity" display Automatically closed - issue fixed for 2 weeks with no activity.
- 🇬🇪Georgia almador
When applying the patch on Drupal 10.3.1
Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2024-02-05/3180541-48.patch
I'm using the Commerce Core 2.39 (tried also with dev version)
My error code:
Drupal\Component\Plugin\Exception\MissingValueContextException: Required contexts without a value: commerce_product
Here is the Call stack:
Drupal\Core\Plugin\Context\ContextHandler->applyContextMapping (\home\user\site\public_html\core\lib\Drupal\Core\Plugin\Context\ContextHandler.php:150) Drupal\block\BlockAccessControlHandler->checkAccess (\home\user\site\public_html\core\modules\block\src\BlockAccessControlHandler.php:92) Drupal\Core\Entity\EntityAccessControlHandler->access (\home\user\site\public_html\core\lib\Drupal\Core\Entity\EntityAccessControlHandler.php:109) Drupal\Core\Entity\EntityBase->access (\home\user\site\public_html\core\lib\Drupal\Core\Entity\EntityBase.php:329) Drupal\block\BlockRepository->getVisibleBlocksPerRegion (\home\user\site\public_html\core\modules\block\src\BlockRepository.php:63) Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build (\home\user\site\public_html\core\modules\block\src\Plugin\DisplayVariant\BlockPageVariant.php:138) Drupal\Core\Render\MainContent\HtmlRenderer->prepare (\home\user\site\public_html\core\lib\Drupal\Core\Render\MainContent\HtmlRenderer.php:270) Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse (\home\user\site\public_html\core\lib\Drupal\Core\Render\MainContent\HtmlRenderer.php:128) Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray (\home\user\site\public_html\core\lib\Drupal\Core\EventSubscriber\MainContentViewSubscriber.php:90) call_user_func:{/app/public_html/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php:111} (\home\user\site\public_html\core\lib\Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher.php:111) Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch (\home\user\site\public_html\core\lib\Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher.php:111) Symfony\Component\HttpKernel\HttpKernel->handleRaw (\home\user\site\vendor\symfony\http-kernel\HttpKernel.php:186) Symfony\Component\HttpKernel\HttpKernel->handle (\home\user\site\vendor\symfony\http-kernel\HttpKernel.php:76) Drupal\Core\StackMiddleware\Session->handle (\home\user\site\public_html\core\lib\Drupal\Core\StackMiddleware\Session.php:53) Drupal\Core\StackMiddleware\KernelPreHandle->handle (\home\user\site\public_html\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php:48) Drupal\Core\StackMiddleware\ContentLength->handle (\home\user\site\public_html\core\lib\Drupal\Core\StackMiddleware\ContentLength.php:28) Drupal\page_cache\StackMiddleware\PageCache->pass (\home\user\site\public_html\core\modules\page_cache\src\StackMiddleware\PageCache.php:106) Drupal\page_cache\StackMiddleware\PageCache->handle (\home\user\site\public_html\core\modules\page_cache\src\StackMiddleware\PageCache.php:85) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle (\home\user\site\public_html\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php:48) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle (\home\user\site\public_html\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php:51) Drupal\Core\StackMiddleware\AjaxPageState->handle (\home\user\site\public_html\core\lib\Drupal\Core\StackMiddleware\AjaxPageState.php:36) Drupal\Core\StackMiddleware\StackedHttpKernel->handle (\home\user\site\public_html\core\lib\Drupal\Core\StackMiddleware\StackedHttpKernel.php:51) Drupal\Core\DrupalKernel->handle (\home\user\site\public_html\core\lib\Drupal\Core\DrupalKernel.php:741) {main} (\home\user\site\public_html\index.php:19)