productDetailViews event is fired very rarely, because hook_entity_view is invoked only once after each cache rebuild.
Is it expected behavior?
I assume productDetailViews is expected to be fired on every product details page load.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | interdiff-3074305-08-11.txt | 9.15 KB | wengerk |
| #11 | 3074305-11.patch | 8.41 KB | wengerk |
| #11 | 3074305-11--should-fail.patch | 2.26 KB | wengerk |
Comments
Comment #2
zeutyPatch that fixes the issue by moving productDetailsView event generation from hook_entity_view to Kernel Request Event.
Comment #3
zeutyComment #4
wengerkComment #5
wengerkHey Zeuty, Thanks for helping us on this issue !!
Do you need any help to update the tests ?
Comment #6
zeutyComment #7
zeutyPlease review the patch.
Functionality change:
Earlier productDetailViews was fired in commerce_google_tag_manager_commerce_product_view (hook_entity_view implementation), which is not the right one for the event, as it is not executed on every product details page load.
In patch productDetailViews execution is moved to KernelEvents::REQUEST event subscriber, so we can guarantee that it is fired during every product details page load.
Comment #8
zeutyAdded some comments to clarify why priority 28 is used.
Comment #9
wengerkMany thanks for your help !
I think, we should add a tests that show why the previous code didn't now works.
I mean:
Once done, we would be sure we close an important issue & we cover any regression on this.
What do you think ?
Comment #10
zeuty@Wengerk, agreed, I will work on this.
Comment #11
wengerkHey guys, happy to finally got times get working on this issue !!
So here is a patch reroll, containing improvements and tests coverage !
I also upload a "should-fail" patch to ensure the bug has been covered.
Let's test all of that via testbot !
Comment #12
wengerkComment #13
wengerk