Repository navigation
Conversation
prepareItemListFromProductList() already loads the categories of a whole list at once, but the variant label of each product with a combination still ran its own query: one per product on category pages. The labels of the list's combinations are now loaded in one query and kept by the wrapper; getProductVariant() reads them, and loads a missing one as before.
|
Hello @boo-code! This is your first pull request on ps_googleanalytics repository of the PrestaShop project. Thank you, and welcome to this Open Source community! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ProductWrapper::prepareItemListFromProductList()already loads the categories of the whole list in one go (loadCategories()), butprepareItemFromProduct()then calledgetProductVariant()for each product with a combination, oneproduct_attribute_combinationquery per product: 8 on the demo shop's category page of 12 products.The list now collects the combinations whose label is not provided (
attributes_small) and loads their labels in one query, ordered as before (attribute group position, then attribute position, per combination), kept by the wrapper.getProductVariant()keeps its signature, reads the loaded label and loads a missing one as before; it returns an empty string for a combination without attributes, as the previousimplode()did.develop, Hummingbird, demo data, a GA4 ID configured. Queries counted with the MySQL general log for one request.Variant queries: category
/2-home8 -> 1,/6-accessories6 -> 1.The
item_idanditem_variantvalues printed on the category, Clothes, Accessories, product and home pages are identical with and without this change (85 values, 33 of them variants, including multi-attribute ones such asS - White).PHPStan (level 5, against PrestaShop
develop) and php-cs-fixer pass.