Skip to content

Conversation

@ihor-sviziev
Copy link
Contributor

Description

I noticed that some product pages loaded pretty fast while others did not. I did profiling and noticed that Klaviyo Viewed Product block was loading about 0.26-0.3 seconds on my pretty fast machine, which is very big number. That was caused by loading all linked category models in the loop (some products have 150+ categories).
To improve this situation, I replaced the loading category model in the loop with using a single collection call with fetching only needed info (category name). That worked way faster on the same machine- about 0.007 vs 0.3 seconds.

Manual Testing Steps

  1. Create product and link it to 150+ categories
  2. Enable Magento profiler with php bin/magento dev:profiler:enable and see how long klaviyo block is getting rendered.
  3. Apply the patch
  4. Compare results between the measurements

Pre-Submission Checklist:

  • You've updated the CHANGELOG following the steps here
  • Internal Only - If this is a release, please confirm the following:
    • The links in the changelog have been updated to point towards the new versions
    • The version has been incremented in the following places: module.xml and composer.json

NOTE: Please use the Changelogger cli tool to manage versioned file upgrades.

@ihor-sviziev ihor-sviziev requested a review from a team as a code owner April 26, 2023 07:21
@klaviyoit klaviyoit requested a review from cykolln April 26, 2023 07:21
@ihor-sviziev
Copy link
Contributor Author

I see a related PR #130, but it has a limit of 30 categories. I am wondering if that's expected. In comparison, my PR isn't adding any difference to the result.

Copy link
Contributor

@cykolln cykolln left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing! Happy to approve, can you please update the changelog and add this update to Unreleased under Fixed. You can use the changelogger tool: changelogger unreleased add to add this change

@ihor-sviziev ihor-sviziev requested a review from cykolln April 27, 2023 07:20
@cykolln cykolln merged commit 91b6c3b into klaviyo:master Apr 27, 2023
@ihor-sviziev ihor-sviziev deleted the patch-1 branch April 27, 2023 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants