The key splitting feature might potentially expose some JavaScript coding issues in the
store JSP pages. JSP pages that passed or initialized JSTL variables of object's primary keys (or
identifiers) into JavaScript variables as integers might be subject to unexpected behavior in the
storefront.
For example:
<script>
var catentryId = <c:out value="${WCParam.productId}"/>;
</script>
Where the issue with the above code snippet is that the JavaScript variable being initialized is
treated as an integer. In JavaScript, the highest integer value is 9 007 199 254 740
992
. When key splitting, the range becomes much higher than that and thus causes problems
in the JavaScript. The symptoms are that higher numbers are likely ignored and the threshold cap
causes unexpected behavior in the storefront. For example, adding an item to the cart might add an
unintended product to the cart instead.
Procedure
- Using a string in JavaScript solves this issue. Therefore,
the preceding code sample above updates to:
<script>
var catentryId = "<c:out value="${WCParam.productId}"/>";
</script>
Where encapsulating the value in quotes (") ensures that
the value is a string.
- If you are using key splitting and the Aurora starter store, you must update the JavaScript accordingly.
The
following files must be updated:
- For the Aurora starter store:
- WC_eardir/Stores.war/storedir/Widgets/Header/Header_UI.jspfxc_workspace_dir\crs-custom-web\WebContent\storedir\Widgets\Header\Header_UI.jspf
- Change
analyticsJS.storeId=<c:out value="${storeId}"/>;
analyticsJS.catalogId=<c:out value="${catalogId}"/>;
To:
analyticsJS.storeId="<c:out value="${storeId}"/>";
analyticsJS.catalogId="<c:out value="${catalogId}"/>";
- WC_eardir/Stores.war/storedir/Layouts/SearchResultsDisplay.jspxc_workspace_dir\crs-custom-web\WebContent\storedir\ShoppingArea\CatalogSection\SearchSubsection\SearchResultsDisplay.jsp
- Change
analyticsJS.storeId=<c:out value="${storeId}"/>;
analyticsJS.catalogId=<c:out value="${catalogId}"/>;
To:
analyticsJS.storeId="<c:out value="${storeId}"/>";
analyticsJS.catalogId="<c:out value="${catalogId}"/>";
- WC_eardir/Stores.war/storedir/Snippets/Order/Cart/OrderItemDetail.jspxc_workspace_dir\crs-custom-web\WebContent\storedir\Snippets\Order\Cart\OrderItemDetail.jsp
- Change
analyticsJS.storeId="<c:out value=${WCParam.storeId}" />;
analyticsJS.catalogId="<c:out value=${WCParam.catalogId}" />;
To:
analyticsJS.storeId="<c:out value="${WCParam.storeId}" />";
analyticsJS.catalogId="<c:out value="${WCParam.catalogId}" />";
- WC_eardir/Stores.war/storedir/Widgets/CompareProduct/CompareProduct_UI.jspfxc_workspace_dir\crs-custom-web\WebContent\storedir\Widgets\CompareProduct\CompareProduct_UI.jspf
- Change
CompareProductJS.add2ShopCart(${catEntryType.key},1,${catEntryId});"
To:
CompareProductJS.add2ShopCart('${catEntryType.key}',1,'${catEntryId}');"