Not sure if this should be treated as a bug, or as an undocumented feature.
In the Runtime_ProductList_Load_Offset_Category(...), "products var" array does not get erased automatically for every new request.
If current requested category has less products then the previous requested category, the front of the array will be replaced with latest results, but the tail will not be truncated and will contain leftovers from previous request. So array stretches as much as we need, but does not shrink on its own. Should it be?
In case of 10 products in the "cat-A" and 6 products in the "cat-B" the output will be:
cat-A
prod-1-cat-A
prod-2-cat-A
prod-3-cat-A
prod-4-cat-A
prod-5-cat-A
prod-6-cat-A
prod-7-cat-A
prod-8-cat-A
prod-9-cat-A
prod-10-cat-A
cat-B
prod-1-cat-B
prod-2-cat-B
prod-3-cat-B
prod-4-cat-B
prod-5-cat-B
prod-6-cat-B
prod-7-cat-A <--- leftover of cat-A
prod-8-cat-A <--- leftover of cat-A
prod-9-cat-A <--- leftover of cat-A
prod-10-cat-A <--- leftover of cat-A
Sure enough, if every iteration we assign l.settings:myProducts to null, result will be as expected with no leftovers.
In the Runtime_ProductList_Load_Offset_Category(...), "products var" array does not get erased automatically for every new request.
If current requested category has less products then the previous requested category, the front of the array will be replaced with latest results, but the tail will not be truncated and will contain leftovers from previous request. So array stretches as much as we need, but does not shrink on its own. Should it be?
Code:
<mvt:comment>ASSIGNING CATEGORIES</mvt:comment> <mvt:assign name="l.cats[1]" value="'cat-A" /> <mvt:assign name="l.cats[2]" value="'cat-B" /> <mvt:assign name="l.settings:cats" value="l.cats" /> <mvt:foreach iterator="cat" array="cats"> <mvt:do name="l.doit" file="g.module_library_db" value="Category_Load_Code( l.settings:cat, l.settings:thisCategory)" /> <mvt:do name="l.doit" file="g.module_library_db" value="Runtime_ProductList_Load_Offset_Category( l.settings:thisCategory:id, 0, 0, g.NextOffset, l.settings:myProducts )" /> <br><br>&mvt:cat;<br> <mvt:foreach iterator="product" array="myProducts"> &mvt:product:name; <br> </mvt:foreach> </mvt:foreach>
cat-A
prod-1-cat-A
prod-2-cat-A
prod-3-cat-A
prod-4-cat-A
prod-5-cat-A
prod-6-cat-A
prod-7-cat-A
prod-8-cat-A
prod-9-cat-A
prod-10-cat-A
cat-B
prod-1-cat-B
prod-2-cat-B
prod-3-cat-B
prod-4-cat-B
prod-5-cat-B
prod-6-cat-B
prod-7-cat-A <--- leftover of cat-A
prod-8-cat-A <--- leftover of cat-A
prod-9-cat-A <--- leftover of cat-A
prod-10-cat-A <--- leftover of cat-A
Sure enough, if every iteration we assign l.settings:myProducts to null, result will be as expected with no leftovers.
Comment