Namespace related/up-sell item ids so the blocks stop hiding each other (#37482) - #41171
Namespace related/up-sell item ids so the blocks stop hiding each other (#37482)#41171lbajsarowicz wants to merge 3 commits into
Conversation
…ers visibility On a PDP with both upsell and related products with a limit set and a shared set of some of the products an issue could arise where products being hidden or shown by the related product js would impact the upsell products and vice versa.
Covers the fix for magento#37482: when the same product is assigned as both a Related Product and an Up-Sell Product, verifies each block renders it with a distinct, block-namespaced DOM id and that neither block's hide-on-load script suppresses the other block's entry.
|
@magento run all tests |
|
Hi @lbajsarowicz. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
The original PR's second commit was dropped during the rebase as cosmetic. It was not: the Magento2 sniff warns on every $block->escape* call in a touched template, and the upstream Static Tests build fails on warnings. Convert the 31 call sites to $escaper, wrap the lines the two extra characters push past 120, and wrap the over-long lines in the new MFTF test.
3e2e4fa to
c1ca4fc
Compare
|
@magento run all tests |
|
@magento create issue |
|
@lbajsarowicz thank you for picking this up. I haven't seen the updates nor the time to look into this. Would be great if this can get resolved for others as well. |
Description
When the same product is assigned as both a Related Product and an Up-Sell Product, the two blocks fight over each other's visibility: an item shown in one block disappears from the other.
app/code/Magento/Catalog/view/frontend/templates/product/list/items.phtmlrenders every related and up-sell item with an id derived only from the product:and then emits a hide rule through
$secureRenderer->renderStyleAsTag('display:none;', 'li#product-item_' . $_item->getId()).Two consequences, both present on current
2.4-develop:<li>for that product, and vice versa.The fix namespaces the id by block type, so each block gets its own element and its own selector.
This PR continues #37482 by @igorwulff (Partner: Youwe), rebased onto current
2.4-develop. Their commit and authorship are preserved.Fixed Issues
No linked issue on the original PR; the defect is described above and is reproducible on current
2.4-develop.Manual testing scenarios
id="product-item_<B>".After: product B appears in both blocks, with distinct ids
product-item-related_<B>andproduct-item-upsell_<B>.Questions or comments
The only feedback ever left on the original PR was @engcom-Hotel asking for automated coverage:
That is what this adds:
StorefrontRelatedAndUpsellSharedProductVisibilityTestassigns one product as both a Related and an Up-Sell product, then asserts there is exactly oneli#product-item-related_<id>and exactly oneli#product-item-upsell_<id>, that nothing matches the old collapsedli#product-item_<id>, and that neither element computes todisplay: none.One note on reading that test: under the default configuration there is no item limit on these blocks, so the "both are visible" assertions alone would pass even without the fix. The assertions that actually pin the regression are the id-uniqueness ones and the absence of the legacy id.
Verified locally on
2.4-develop:testSchema.xsd, and all eight action groups it references exist in core.git grepconfirms the oldproduct-item_<id>id is referenced nowhere else in core — no JS, LESS, CSS or template depends on it, so the rename is self-contained. (The@product-item__hover__*hits in Luma's LESS are unrelated variables.)The original PR also carried a second commit that rewrote the copyright header and renamed
$block->escape*to$escaper->escape*. That was purely cosmetic, conflicted with changes upstream has since made itself, and added nothing to the fix, so it was dropped during the rebase — this PR is limited to the id change.Contribution checklist
Resolved issues: