yireo / Yireo_GoogleTagManager2

Open Software License 3.0
147 stars 76 forks source link

Necessary To Load Products In Cart / Checkout? #194

Closed sprankhub closed 9 months ago

sprankhub commented 1 year ago

Still / again doing some profiling... I saw that in the cart and checkout, the extension fully loads all products from all quote items, which takes quite some time:

image

image

Do we really need to fully load the product in the cart / checkout?

By the way, mapByProduct is so expensive due to the loading of all categories:

image

sprankhub commented 1 year ago

@jissereitsma, do you have any thoughts on this? Thanks!

jissereitsma commented 1 year ago

Good point. My thoughts? This should prevented. However, it requires some magic to do so. With the products, I already created now a draft for this: Introducing a new class that collects all product SKUs first, then fetches data for all SKUs at once, and then reuses them. https://github.com/yireo/Yireo_GoogleTagManager2/commit/f89fc8b80526c18feac85a0fec4d475d0f8d15bb

Perhaps this can also be used for categories. I'm on a holiday soon, so can only pick this up in 2 weeks time.

rhoerr commented 11 months ago

Ran into this same thing while profiling for a client. The GTM data loading and rendering (products and categories) takes 30 seconds for us on a 300-item cart, ~90ms/product.

In our case we're not even sending any custom product attrs, so the loading is unnecessary, all product data is already on the cart item product.

jissereitsma commented 11 months ago

Thanks @rhoerr for chiming in. The product load should be a lot less now already, but I'll still work on the same thing with categories. And indeed the "hydration" seems a bit much if it is not needed after all - I'll also check for that to see if that can be made more flexible.

jissereitsma commented 9 months ago

The previous fix already brought the load down to a minimum, but with the new release 3.7.6 I also refactored the categories part, so far less queries are needed.

As of yet, I'm closing this issue, but let me know if this is still bugging.