public class CommerceHelper
extends java.lang.Object
Constructor and Description |
---|
CommerceHelper() |
Modifier and Type | Method and Description |
---|---|
static void |
collectVariants(Resource resource,
java.util.Map<java.lang.String,Product> variations)
Collects up a map of product variations (including the base product) under a given subtree.
|
static boolean |
copyTags(Product source,
Resource dest,
Predicate filter)
Copies a filtered list of tags from a Product to another Resource.
|
static Product |
findCurrentProduct(Page currentPage)
Finds the current
Product for a product page. |
static Resource |
findProductResource(Page page)
Finds the current product resource for a page.
|
static Resource |
findProductResource(Resource resource)
Finds a product resource at or below the provided resource's path.
|
static java.lang.String |
getCardTitle(Resource resource,
PageManager pageManager)
Return a title suitable for a card in the touch-optimized GUI.
|
static java.lang.String |
getCatalogCardThumbnail(java.lang.String contextPath,
Resource resource,
PageManager pageManager)
Returns a thumbnail for a card in the catalogs console.
|
static java.lang.String |
getProductCardThumbnail(java.lang.String contextPath,
Product product)
Return an externalized URL to a product's thumbnail image.
|
static java.util.Comparator<Product> |
getProductSizeComparator()
Handles comparison of product "size" fields containing either numeric or letter sizes.
|
static java.lang.String |
mapPathToCurrentLanguage(Page currentPage,
java.lang.String srcPath)
Maps a designer-supplied resource path (such as /content/geometrixx-outdoors/language-masters/en/user/cart)
to the current language (ie: /content/geometrixx-outdoors/de/de/user/cart).
|
static void |
writeCart(JSONWriter writer,
CommerceSession commerceSession)
Writes a cart to JSON for the CartMgr ClientContextStore.
|
static void |
writeCart(JSONWriter writer,
CommerceSession commerceSession,
ResourceResolver resolver)
Deprecated.
since 6.1
|
static void |
writeCart(JSONWriter writer,
CommerceSession commerceSession,
ResourceResolver resolver,
SlingHttpServletRequest request)
Deprecated.
since 6.1 (moved to ClientContextCartServlet)
|
static void |
writeOrderHistory(JSONWriter writer,
PlacedOrderResult orderHistory,
OrderHistoryTraitDataProvider[] services)
Writes order history trait data to JSON for the OrderHistoryMgr ClientContextStore.
|
public static java.lang.String mapPathToCurrentLanguage(Page currentPage, java.lang.String srcPath)
currentPage
- The page being rendered (which controls the language selection)srcPath
- The resource path (usually given in the design language)public static java.util.Comparator<Product> getProductSizeComparator()
java.util.Comparator
public static Product findCurrentProduct(Page currentPage)
Product
for a product page. This will be the first Product
node or reference within the page's content.currentPage
- The page to search inProduct
for a product pagefindProduct(Resource)
public static Resource findProductResource(Page page)
cq:commerceType
property of product
. As opposed to findCurrentProduct(com.day.cq.wcm.api.Page)
, this will not
try to adapt the resource to a Product
, so it will work even for yet-unfilled resources.page
- The page to search incq:commerceType='product'
resource, or null
if it doesn't existfindProductResource(org.apache.sling.api.resource.Resource)
public static Resource findProductResource(Resource resource)
findProduct(org.apache.sling.api.resource.Resource)
, this will not try to adapt the resource to a
Product
, so it will work even for yet-unfilled resources.resource
- The resource to start fromcq:commerceType='product'
resource, or null
if it doesn't existfindProductResource(com.day.cq.wcm.api.Page)
public static void collectVariants(Resource resource, java.util.Map<java.lang.String,Product> variations)
resource
- variations
- public static boolean copyTags(Product source, Resource dest, Predicate filter) throws RepositoryException
source
- dest
- filter
- A Predicate
which is passed each com.day.cq.tagging.Tag
.true
if any tags were copiedRepositoryException
public static void writeCart(JSONWriter writer, CommerceSession commerceSession) throws CommerceException, JSONException
writer
- A JSONWriter
instancecommerceSession
- The commerce sessionCommerceException
JSONException
@Deprecated public static void writeCart(JSONWriter writer, CommerceSession commerceSession, ResourceResolver resolver) throws CommerceException, JSONException
writer
- A JSONWriter
instancecommerceSession
- The commerce sessionresolver
- The resource resolverCommerceException
JSONException
@Deprecated public static void writeCart(JSONWriter writer, CommerceSession commerceSession, ResourceResolver resolver, SlingHttpServletRequest request) throws CommerceException, JSONException
writer
- A JSONWriter
instancecommerceSession
- The commerce sessionresolver
- The resource resolverrequest
- The current requestCommerceException
JSONException
public static void writeOrderHistory(JSONWriter writer, PlacedOrderResult orderHistory, OrderHistoryTraitDataProvider[] services) throws CommerceException, JSONException
writer
- A JSONWriter
instanceorderHistory
- the placed ordersservices
- the order history trait data provider servicesCommerceException
JSONException
public static java.lang.String getCatalogCardThumbnail(java.lang.String contextPath, Resource resource, PageManager pageManager)
contextPath
- the request's contextPathpublic static java.lang.String getCardTitle(Resource resource, PageManager pageManager)
resource
- pageManager
- public static java.lang.String getProductCardThumbnail(java.lang.String contextPath, Product product)
contextPath
- the request's contextPath"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"