Skip to content

Instantly share code, notes, and snippets.

@leopic
Created January 3, 2013 20:48
Show Gist options
  • Save leopic/4447122 to your computer and use it in GitHub Desktop.
Save leopic/4447122 to your computer and use it in GitHub Desktop.
diff --git a/modules/Store/j2ee-apps/Store/Store.war/catalog/include/productBuyBox.jsp b/modules/Store/j2ee-apps/Store/Store.war/catalog/include/productBuyBox.jsp
index a85d870..b07ec5b 100644
--- a/modules/Store/j2ee-apps/Store/Store.war/catalog/include/productBuyBox.jsp
+++ b/modules/Store/j2ee-apps/Store/Store.war/catalog/include/productBuyBox.jsp
-8,6 +8,7 @@
<dsp:importbean bean="/backcountry/catalog/droplet/ProductFreeGiftDroplet" />
<dsp:importbean bean="/backcountry/common/droplet/BikeFitGuideDroplet" />
<dsp:importbean bean="/backcountry/util/droplet/IsFeatureEnabledDroplet" />
+<dsp:importbean bean="/backcountry/common/droplet/BuyBoxDataLoaderDroplet"/>"
<dsp:getvalueof id="productId" param="product.id"/>
<dsp:getvalueof id="quantity" param="quantity" />
-166,6 +167,22 @@
</dsp:oparam>
<dsp:oparam name="default">
+
+ <%-- data structure with product's colors and sizes collections --%>
+ <c:if test="${isNewBuyBoxEnabled}">
+ <dsp:droplet name="BuyBoxDataLoaderDroplet">
+ <dsp:param name="availableChildSkus" param="availableChildSkus"/>
+ <dsp:oparam name="output">
+ <dsp:getvalueof var="sizesCollectionJSON" vartype="string" param="sizesCollectionJSON"/>
+ <dsp:getvalueof var="colorsCollectionJSON" vartype="string" param="colorsCollectionJSON"/>
+ <script type="text/javascript">
+ BC.product.sizesCollection = $.parseJSON('${bc:escapeJavaScript(sizesCollectionJSON)}');
+ BC.product.colorsCollection = $.parseJSON('${bc:escapeJavaScript(colorsCollectionJSON)}');
+ </script>
+ </dsp:oparam>
+ </dsp:droplet>
+ </c:if>
+
<%-- exposing quantity for use in Selenium `getAvailableInventory` method --%>
<input type="hidden" id="availability" value="<dsp:valueof param="quantity"/>" />
<dsp:form requiresSessionConfirmation="false" method="post" iclass="add-to-cart-form" id="add-to-cart-form" action="/Store/catalog/productLanding.jsp?productId=${productId}">
-299,13 +316,7 @@
<dsp:param name="endHTML" value="</li>"/>
</dsp:include>
</ul>
-
-
- <%--<a href="https://www.securecheckout.billmelater.com/paycapture-content/fetch?hash=88D318UD&content=/bmlweb/np90drollingiw.html"
- data-ui='{"newwindow": {"width":520,"height":395}}'
- class="new-window-link bml-link">
- <img src="http://www.hucknroll.com/images/bml/bml-logo.png"/>
- </a>--%>
+
</dsp:form>
</dsp:oparam>
</dsp:droplet>
diff --git a/modules/Store/src/com/backcountry/common/droplet/BuyBoxDataLoaderDroplet.java b/modules/Store/src/com/backcountry/common/droplet/BuyBoxDataLoaderDroplet.java
index 99715cb..8ebb167 100644
--- a/modules/Store/src/com/backcountry/common/droplet/BuyBoxDataLoaderDroplet.java
+++ b/modules/Store/src/com/backcountry/common/droplet/BuyBoxDataLoaderDroplet.java
-33,12 +33,11 @@ import com.backcountry.catalog.model.constants.SkuConstants;
*/
public class BuyBoxDataLoaderDroplet extends DynamoServlet {
- public static final String SIZES_JSON_OPARAM = "sizesJson";
- public static final String COLORS_JSON_OPARAM = "colorsJson";
+ public static final String SIZES_JSON_OPARAM = "sizesCollectionJSON";
+ public static final String COLORS_JSON_OPARAM = "colorsCollectionJSON";
public static final String IMAGE = "image";
public static final String TEXT = "text";
public static final String TYPE = "type";
- public static final String DISPLAY_NAME = "displayName";
public static final String COLLECTION_AXES = "axes";
public static final String OUTPUT_OPARAM = "output";
public static final String ERROR_OPARAM = "error";
-83,13 +82,12 @@ public class BuyBoxDataLoaderDroplet extends DynamoServlet {
// includes color in colors collection
this.updateAttributesCollection(colorsCollection, availableChildSkuItem, skuSize, skuTinyImageUrl,
- (String) availableChildSkuItem.getPropertyValue(SkuConstants.COLOR), IMAGE);
+ IMAGE);
// includes size in size collection
// TODO get the size name (for example, for a size "M",
// display "Medium") should it be a mapping from where?
- this.updateAttributesCollection(sizesCollection, availableChildSkuItem, skuTinyImageUrl, skuSize,
- skuSize, TEXT);
+ this.updateAttributesCollection(sizesCollection, availableChildSkuItem, skuTinyImageUrl, skuSize, TEXT);
}
pRequest.setParameter(COLORS_JSON_OPARAM, new JSONObject(colorsCollection).toString());
-150,7 +148,7 @@ public class BuyBoxDataLoaderDroplet extends DynamoServlet {
* @param pKeyAttributeType
*/
private void updateAttributesCollection(Map<String, Map<String, Object>> pAttributeCollection,
- RepositoryItem pSkuItem, String pSkuAxisAttribute, String pKeySkuAttribute, String pKeySkuAttributeDisplayName, String pKeyAttributeType) {
+ RepositoryItem pSkuItem, String pSkuAxisAttribute, String pKeySkuAttribute, String pKeyAttributeType) {
Map<String, String> pAxesAttributesCollectionPerKeyAttribute;
if (!StringUtils.isBlank(pKeySkuAttribute)) {
if (pAttributeCollection.containsKey(pKeySkuAttribute)) {
-171,7 +169,6 @@ public class BuyBoxDataLoaderDroplet extends DynamoServlet {
}
Map<String, Object> keySkuAttributeCollection = new HashMap<String, Object>();
- keySkuAttributeCollection.put(DISPLAY_NAME, pKeySkuAttributeDisplayName);
keySkuAttributeCollection.put(TYPE, pKeyAttributeType);
keySkuAttributeCollection.put(COLLECTION_AXES, pAxesAttributesCollectionPerKeyAttribute);
diff --git a/modules/Store/test/src/com/backcountry/common/droplet/BuyBoxDataLoaderDropletTest.java b/modules/Store/test/src/com/backcountry/common/droplet/BuyBoxDataLoaderDropletTest.java
index 682bd22..6a7b3ed 100644
--- a/modules/Store/test/src/com/backcountry/common/droplet/BuyBoxDataLoaderDropletTest.java
+++ b/modules/Store/test/src/com/backcountry/common/droplet/BuyBoxDataLoaderDropletTest.java
-49,45 +49,38 @@ public class BuyBoxDataLoaderDropletTest {
// multiSizesPerColor
private static String[][] skuCollection_multiSizesPerColor = {
- { "BCC0262-BK-S", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg", "Black", "S", "S" },
- { "BCC0262-BK-XL", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg", "Black", "XL", "XL" },
- { "BCC0262-HEGY-S", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "Heather Gray", "S",
- "S" },
- { "BCC0262-HEGY-M", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "Heather Gray", "M",
- "M" },
- { "BCC0262-HEGY-L", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "Heather Gray", "L",
- "L" },
- { "BCC0262-HEGY-XL", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "Heather Gray", "XL",
- "XL" },
- { "BCC0262-HEGY-XXL", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "Heather Gray",
- "XXL",
- "XXL" } };
-
- private static String colorsCollection_multiSizesPerColor = "{\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg\":{\"displayName\":\"Black\",\"type\":\"image\",\"axes\":{\"S\":\"BCC0262-BK-S\",\"XL\":\"BCC0262-BK-XL\"}},\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg\":{\"displayName\":\"Heather Gray\",\"type\":\"image\",\"axes\":{\"S\":\"BCC0262-HEGY-S\",\"XXL\":\"BCC0262-HEGY-XXL\",\"L\":\"BCC0262-HEGY-L\",\"M\":\"BCC0262-HEGY-M\",\"XL\":\"BCC0262-HEGY-XL\"}}}";
- private static String sizesCollection_multiSizesPerColor = "{\"S\":{\"displayName\":\"S\",\"type\":\"text\",\"axes\":{\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg\":\"BCC0262-BK-S\",\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg\":\"BCC0262-HEGY-S\"}},\"XXL\":{\"displayName\":\"XXL\",\"type\":\"text\",\"axes\":{\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg\":\"BCC0262-HEGY-XXL\"}},\"L\":{\"displayName\":\"L\",\"type\":\"text\",\"axes\":{\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg\":\"BCC0262-HEGY-L\"}},\"M\":{\"displayName\":\"M\",\"type\":\"text\",\"axes\":{\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg\":\"BCC0262-HEGY-M\"}},\"XL\":{\"displayName\":\"XL\",\"type\":\"text\",\"axes\":{\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg\":\"BCC0262-BK-XL\",\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg\":\"BCC0262-HEGY-XL\"}}}";
+ { "BCC0262-BK-S", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg", "S" },
+ { "BCC0262-BK-XL", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg", "XL" },
+ { "BCC0262-HEGY-S", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "S" },
+ { "BCC0262-HEGY-M", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "M" },
+ { "BCC0262-HEGY-L", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "L" },
+ { "BCC0262-HEGY-XL", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "XL" },
+ { "BCC0262-HEGY-XXL", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "XXL" } };
+
+ private static String colorsCollection_multiSizesPerColor = "{\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg\":{\"type\":\"image\",\"axes\":{\"S\":\"BCC0262-BK-S\",\"XL\":\"BCC0262-BK-XL\"}},\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg\":{\"type\":\"image\",\"axes\":{\"S\":\"BCC0262-HEGY-S\",\"XXL\":\"BCC0262-HEGY-XXL\",\"L\":\"BCC0262-HEGY-L\",\"M\":\"BCC0262-HEGY-M\",\"XL\":\"BCC0262-HEGY-XL\"}}}";
+ private static String sizesCollection_multiSizesPerColor = "{\"S\":{\"type\":\"text\",\"axes\":{\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg\":\"BCC0262-BK-S\",\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg\":\"BCC0262-HEGY-S\"}},\"XXL\":{\"type\":\"text\",\"axes\":{\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg\":\"BCC0262-HEGY-XXL\"}},\"L\":{\"type\":\"text\",\"axes\":{\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg\":\"BCC0262-HEGY-L\"}},\"M\":{\"type\":\"text\",\"axes\":{\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg\":\"BCC0262-HEGY-M\"}},\"XL\":{\"type\":\"text\",\"axes\":{\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg\":\"BCC0262-BK-XL\",\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg\":\"BCC0262-HEGY-XL\"}}}";
// noSizesPerColor
private static String[][] skuCollection_noSizesPerColor = {
- { "BCC0262-BK-S", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg", "Black", "", "" },
- { "BCC0262-BK-XL", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg", "Black", "", "" },
- { "BCC0262-HEGY-S", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "Heather Gray", "", "" },
- { "BCC0262-HEGY-M", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "Heather Gray", "", "" },
- { "BCC0262-HEGY-L", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "Heather Gray", "", "" },
- { "BCC0262-HEGY-XL", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "Heather Gray", "", "" },
- { "BCC0262-HEGY-XXL", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "Heather Gray", "",
+ { "BCC0262-BK-S", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg", "" },
+ { "BCC0262-BK-XL", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg", "" },
+ { "BCC0262-HEGY-S", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "" },
+ { "BCC0262-HEGY-M", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "" },
+ { "BCC0262-HEGY-L", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "" },
+ { "BCC0262-HEGY-XL", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "" },
+ { "BCC0262-HEGY-XXL", "//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg", "",
"" } };
- private static String colorsCollection_noSizesPerColor = "{\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg\":{\"displayName\":\"Black\",\"type\":\"image\",\"axes\":{}},\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg\":{\"displayName\":\"Heather Gray\",\"type\":\"image\",\"axes\":{}}}";
+ private static String colorsCollection_noSizesPerColor = "{\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/BK.jpg\":{\"type\":\"image\",\"axes\":{}},\"//www.backcountry.com/images/items/tiny/BCC/BCC0262/HEGY.jpg\":{\"type\":\"image\",\"axes\":{}}}";
private static String sizesCollection_noSizesPerColor = "{}";
// noColorsPerSizes
- private static String[][] skuCollection_noColorsPerSizes = { { "BCC0262-BK-S", "", "Black", "S", "S" },
- { "BCC0262-BK-XL", "", "Black", "XL", "XL" }, { "BCC0262-HEGY-S", "", "", "S", "S" },
- { "BCC0262-HEGY-M", "", "", "M", "M" }, { "BCC0262-HEGY-L", "", "", "L", "L" },
- { "BCC0262-HEGY-XL", "", "", "XL", "XL" }, { "BCC0262-HEGY-XXL", "", "", "XXL", "XXL" } };
+ private static String[][] skuCollection_noColorsPerSizes = { { "BCC0262-BK-S", "", "S" },
+ { "BCC0262-BK-XL", "", "XL" }, { "BCC0262-HEGY-S", "", "S" }, { "BCC0262-HEGY-M", "", "M" },
+ { "BCC0262-HEGY-L", "", "L" }, { "BCC0262-HEGY-XL", "", "XL" }, { "BCC0262-HEGY-XXL", "", "XXL" } };
private static String colorsCollection_noColorsPerSizes = "{}";
- private static String sizesCollection_noColorsPerSizes = "{\"S\":{\"displayName\":\"S\",\"type\":\"text\",\"axes\":{}},\"XXL\":{\"displayName\":\"XXL\",\"type\":\"text\",\"axes\":{}},\"L\":{\"displayName\":\"L\",\"type\":\"text\",\"axes\":{}},\"M\":{\"displayName\":\"M\",\"type\":\"text\",\"axes\":{}},\"XL\":{\"displayName\":\"XL\",\"type\":\"text\",\"axes\":{}}}";
+ private static String sizesCollection_noColorsPerSizes = "{\"S\":{\"type\":\"text\",\"axes\":{}},\"XXL\":{\"type\":\"text\",\"axes\":{}},\"L\":{\"type\":\"text\",\"axes\":{}},\"M\":{\"type\":\"text\",\"axes\":{}},\"XL\":{\"type\":\"text\",\"axes\":{}}}";
@Test
public void testService() throws ServletException, IOException {
-143,8 +136,9 @@ public class BuyBoxDataLoaderDropletTest {
for (String[] availableChildSku : availableChildSkusList) {
RepositoryItem mainImageItem = Mockito.mock(RepositoryItem.class);
RepositoryItem sizeItem = Mockito.mock(RepositoryItem.class);
- RepositoryItem skuItem = this.mockSkuItem(availableChildSku[0], availableChildSku[2], mainImageItem,
- availableChildSku[1], sizeItem, availableChildSku[3], availableChildSku[4]);
+ RepositoryItem skuItem = this.mockSkuItem(availableChildSku[0], mainImageItem,
+ availableChildSku[1],
+ sizeItem, availableChildSku[2]);
childSkusList.add(skuItem);
}
-158,8 +152,8 @@ public class BuyBoxDataLoaderDropletTest {
RepositoryItem sizeItem = null;
for (String[] availableChildSku : availableChildSkusList) {
RepositoryItem mainImageItem = Mockito.mock(RepositoryItem.class);
- RepositoryItem skuItem = this.mockSkuItem(availableChildSku[0], availableChildSku[2], mainImageItem,
- availableChildSku[1], sizeItem, availableChildSku[3], availableChildSku[4]);
+ RepositoryItem skuItem = this.mockSkuItem(availableChildSku[0], mainImageItem, availableChildSku[1],
+ sizeItem, availableChildSku[2]);
childSkusList.add(skuItem);
}
-173,19 +167,18 @@ public class BuyBoxDataLoaderDropletTest {
RepositoryItem mainImageItem = null;
for (String[] availableChildSku : availableChildSkusList) {
RepositoryItem sizeItem = Mockito.mock(RepositoryItem.class);
- RepositoryItem skuItem = this.mockSkuItem(availableChildSku[0], availableChildSku[2], mainImageItem,
- availableChildSku[1], sizeItem, availableChildSku[3], availableChildSku[4]);
+ RepositoryItem skuItem = this.mockSkuItem(availableChildSku[0], mainImageItem, availableChildSku[1],
+ sizeItem, availableChildSku[2]);
childSkusList.add(skuItem);
}
return childSkusList;
}
- private RepositoryItem mockSkuItem(String pSkuId, String pColorName, RepositoryItem mainImageItem,
- String pTinyImageUrl, RepositoryItem sizeItem, String pSize, String pSizeName) {
+ private RepositoryItem mockSkuItem(String pSkuId, RepositoryItem mainImageItem, String pTinyImageUrl,
+ RepositoryItem sizeItem, String pSize) {
RepositoryItem skuItem = Mockito.mock(RepositoryItem.class);
when(skuItem.getPropertyValue(SkuConstants.ID)).thenReturn(pSkuId);
- when(skuItem.getPropertyValue(SkuConstants.COLOR)).thenReturn(pColorName);
when(skuItem.getPropertyValue(SkuConstants.MAIN_IMAGE)).thenReturn(mainImageItem);
if (mainImageItem != null) {
when(mainImageItem.getPropertyValue(SkuConstants.TINY_IMAGE_URL)).thenReturn(pTinyImageUrl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment