-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add child identities to products instead of parent identities #19313
Add child identities to products instead of parent identities #19313
Conversation
…instead of parent identities
Hi @jasperzeinstra. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
@sivaschenko based on our discussion in #19281 i've made this new Pull Request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contribution. Please see the review notes
app/code/Magento/ConfigurableProduct/Model/Plugin/Frontend/ProductIdentitiesExtender.php
Outdated
Show resolved
Hide resolved
Hi @sivaschenko, thank you for the review. |
Hi @jasperzeinstra , it will be great if you can cover the changed functionality with an integration test |
@sivaschenko yeah sure, how can I help with that? |
@jasperzeinstra it will be great if you can add a test to this pull request that checks the tags provided by block and model for configurable and bundle product |
app/code/Magento/ConfigurableProduct/Model/Plugin/Frontend/ProductIdentitiesExtender.php
Outdated
Show resolved
Hide resolved
@sivaschenko i've added the Unit Test classes. |
Thanks for the updates @jasperzeinstra ! Your contribution is extremely valuable and very important for Magento performance and cache management improvement. However, during the group code review activity we decideded that we cannot accept the contribution without proper integration tests that are covering:
I could understand that this is a strict requiremet for you to introduce such tests, however, it would be awesome if you can do this. Otherwise, we will seek internal resources to implement those, however, it can delay the processing of the pull request. Please let me know if you will be able to introduce the integration tests. |
Hello @sivaschenko, Thanks for your reply. I can understand the wishes you have about integration test, but it feels out of scope for this pull request. This PR focuses on configurable and bundle products and the cache tags they are returning. As far as I can see there are no tests for saving a configurable or bundle product. I'm not comfortable with writing them my own. Sorry that I can't help you with finishing this PR in the way you would like to see. |
@jasperzeinstra thanks for the reply, we will ensure a satisfying test coverage and process the pull request as soon as we can |
…le-configurable-product-identies-plugin
Hi @jasperzeinstra, thank you for your contribution! |
Hi @jasperzeinstra. Thank you for your contribution. |
🎉 !!! |
Description
For Bundle and Configurable products the parent identities are added to the default identities with a plugin afterGetIdentities. From my point of view you don't need to have the identities from the parent products on the frontend but from the child products.
We've got a shop with photo cameras. We have a lot of bundle products (570) that include a specific memory card. This specific memory card is also connected as a related product to a lot of products. Currently when you do
getIdentities
on this simple product you will get a very large list of cache tags. And when you ask one of the bundle products for its identities you don't get any of the child products because those aren't added by the plugin. Only the parent identities are added and the bundle itself doesn't have any parent products.From my point of view you don't need to know that a simple product has 570 parent identities, but you do want to know that a bundle has, for example, 5 child identities.
All the identities on a page are also being used by Full Page Cache to create the header
X-Magento-Tags
. This header is also being used by Varnish. But when this header is to big Varnish will stop working. In article https://devdocs.magento.com/guides/v2.2/config-guide/varnish/tshoot-varnish-503.html is described to allow larges headers for Varnish. In this case that isn't very stable. Because when I create 100 more bundle products where this simple product (memory card) is being used i get 100 more cache tags in my header.On a vanilla Magento 2.2.6 shop I duplicated the bundle product 570 times with a SCV import. The result of the
getIdentities
is shown below in a screenshot. Notice that the bundle productSprite Yoga Companion Kit
doesn't contain the identities of the child products. But the simple productSprite Foam Roller
contains all 470 bundle products it's connected to.After the fix I propose the simple product will not show the identities of all the products it's connected to anymore and the bundle product will contain all the identities of the products connected to that product.
Now the identities you're expecting are being returned and the X-Magento-Tags isn't polluted by a lot of cache tags that don't influence the content of the page. You can still run in to the problem that the server won't allow a large header for X-Magento-Tags like described in https://devdocs.magento.com/guides/v2.2/config-guide/varnish/tshoot-varnish-503.html. But at least now the correct cache tags are being returned instead of all the parents of a simple product.
This same issue is also the case for configurable products. For example when a simple product is visible in the catalog and connected to a lot of configurable products this simple product will return a lot of identities and the configurable product won't return the identities of its child products.
Manual testing scenarios
Magento_Catalog::view/frontend/templates/product/list.phtml
and output the entities for each product<?php var_dump($block->getIdentities()); ?>
Contribution checklist