Takes too long to render a product display with 6000+ variations I have a product with several attributes and each one with several options. The total variations is over 6000.
The problem is that rendering takes too long. I've enable Devel module and here are the results:


Executed 72 queries in 323.6 ms.
Page execution time was 13870.81 ms.
Memory used at: devel_boot()=1.44 MB, devel_shutdown()=62.56 MB, PHP peak=69.5 MB.


So I guess there's some bottleneck at the code.

Some notes about the implementation:


I need a unique price for each variation.
I'm using vanilla Drupal Commerce.


There's any way I could improve performance?
Didn't find a proper solution to increase the performance or, at least a clean solution. So I decided to create a module that basically holds an alternative view formatter to the "Add to cart" that comes with Drupal Commerce.

You can find the module here: https://www.drupal.org/sandbox/marcofernandes/2705035

Basically it's a "clone" of "Add to cart" view formatter but it avoids iterations over all variations and field options. It's not perfect but it fits my needs (variations for all possible combinations). I'll keep it as a sandbox until it reaches a more mature state (it lacks some validations and, probably it misses some code styling).