I noticed recently that our basket takes significantly longer to load when there are many items in the cart. I did some testing with debug logs and mvprof and found that with multiple items in the cart (like 50) we get thousands of requests for option lines. With just one item in the cart we get only a few requests. Is this something I can improve with our page template? Here are the first lines from each log:
Full basket:
One item in basket:
Here's a simplified version of our template code for basket contents, the most important things like foreach loops etc are unchanged:
Full basket:
cumulative seconds | self seconds | calls | fastest call | slowest call | name (file) |
2.7338 | 2.7338 | 3444 | 0.000672 | 0.004382 | basketoptionlist_load_line (mm5/5.00/lib/db.mvc) |
One item in basket:
cumulative seconds | self seconds | calls | fastest call | slowest call | name (file) |
0.0910 | 0.0064 | 4 | 0.000751 | 0.003425 | basketoptionlist_load_line (mm5/5.00/lib/db.mvc) |
Here's a simplified version of our template code for basket contents, the most important things like foreach loops etc are unchanged:
HTML Code:
<mvt:foreach iterator="item" array="basket:items"> <tr> <td> <img src="mvt:global:prodThumb;" alt="&mvte:item:name;" height="100" width="100"> </td> <td>&mvt:item:name;</td> <td>&mvt:item:formatted_price;</td> <td> <input class="Quantity&mvte:item:line_id;" type="number" name="Quantity" value="&mvt:item:quantity;"> </td> <td>&mvt:item:formatted_subtotal;</td> </tr> <mvt:item name="toolkit" param="prompt" /> <mvt:if expr="NOT ISNULL l.settings:item:options"> <tr> <td> <table> <mvt:foreach iterator="option" array="item:options"> <tr> <td> <mvt:if expr="l.settings:option:option_id"> <i style="margin-left: 20px;">• &mvt:option:attr_code;: <strong>&mvt:option:opt_prompt;</strong></i> <mvt:elseif expr="NOT ISNULL l.settings:option:data"> <mvt:assign name="AttributeName" value="l.settings:option:attr_code" /> <i style="margin-left: 20px;">• &mvt:global:AttributeName;: <strong>&mvt:option:data;</strong></i> <mvt:elseif expr="NOT ISNULL l.settings:option:data_logn"> <i style="margin-left: 20px;">• &mvt:option:attr_code;: <strong>&mvt:option:data_logn;</strong></i> <mvt:else> <i style="margin-left: 20px;">• &mvt:option:attr_code;</i> </mvt:if> </td> <td> <mvt:if expr="l.settings:option:price"> &mvt:option:formatted_price; </mvt:if> </td> <td></td> <td> <mvt:if expr="l.settings:option:price"> &mvt:option:formatted_subtotal; </mvt:if> </td> </tr> </mvt:foreach> </table> </td> <td></td> </tr> <mvt:else> <tr></tr> </mvt:if> </mvt:foreach> <mvt:foreach iterator="charge" array="basket:charges"> <tr> <td></td> <td><i>&mvt:charge:descrip;:</i></td> <td>&mvt:charge:formatted_disp_amt;</td> <td></td> </tr> </mvt:foreach>
Comment