public abstract class AbstractJcrProduct extends SlingAdaptable implements Product
Product implementation built on top of
a JCR repository. GeoProductImpl is an example.RESOURCE_TYPE_PRODUCT| Constructor and Description |
|---|
AbstractJcrProduct(Resource resource)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
<AdapterType> |
adaptTo(Class<AdapterType> type)
Calls into the registered
AdapterManager to adapt this object to
the desired type. |
boolean |
axisIsVariant(String axis)
Tests a single axis (property) for variation.
|
boolean |
equals(Object obj) |
Resource |
getAsset()
Get the primary asset for this product, or
null if no asset was found. |
List<Resource> |
getAssets()
Get all the assets for this product.
|
List<Resource> |
getAssets(List<String> mimeTypes)
Returns the assets filtered by the mime type
|
Product |
getBaseProduct()
Returns the product which forms the base of a set of variations.
|
String |
getDescription()
Returns the product's description.
|
String |
getDescription(String selectorString)
Returns the product's description based on the given selector.
|
ImageResource |
getImage()
Get the primary image for this product, or
null if no image was found. |
String |
getImagePath()
Deprecated.
|
List<ImageResource> |
getImages()
Get all the images for this product.
|
String |
getImageUrl()
Deprecated.
|
String |
getPagePath()
Get the path of the parent page which renders the product/variation.
|
String |
getPath()
Get the underlying resource's path.
|
Product |
getPIMProduct()
Returns the PIM Product (under /etc/commerce/products) which stores this product's
data.
|
<T> T |
getProperty(String name,
Class<T> type)
Returns a product property.
|
<T> T |
getProperty(String name,
String selectorString,
Class<T> type)
Return a product property based on the given selector.
|
ImageResource |
getThumbnail()
Deprecated.
|
String |
getThumbnailUrl()
Returns the URL to the product's thumbnail image.
|
String |
getThumbnailUrl(int width)
Returns the URL to the product's thumbnail image, resized to the specified width.
|
String |
getThumbnailUrl(String selectorString)
When the
selectorString contains "image", it returns the thumbnail based on the product image by
calling getImage(), otherwise it returns the thumbnail based on the product asset by calling
getAsset() |
String |
getTitle()
Returns the product's title.
|
String |
getTitle(String selectorString)
Returns the product's title based on the given selector.
|
Iterator<String> |
getVariantAxes()
Returns an iterator over the property names of the variant axes.
|
Iterator<Product> |
getVariants()
Returns an iterator over the list of all product variations to which this
particular product/variant belongs.
|
Iterator<Product> |
getVariants(VariantFilter filter)
Returns an iterator over the list of product variants for this product filtered by
the
VariantFilter. |
int |
hashCode() |
static boolean |
isABaseProduct(Resource resource)
Returns true if resource's cq:commerceType is "product".
|
static boolean |
isAProductOrVariant(Resource resource)
Returns true if resource's cq:commerceType is "product" or "variant".
|
static boolean |
isAVariant(Resource resource)
Returns true if resource's cq:commerceType is "variant".
|
setAdapterManager, unsetAdapterManagerpublic AbstractJcrProduct(Resource resource)
resource - the Resource storing the product (or variant) infopublic String getPath()
Productpublic String getPagePath()
ProductgetPagePath in interface Productpublic String getTitle()
Productpublic String getTitle(String selectorString)
ProductThe selector is often a language token, but could also be a regional identifier or some other discriminator.
public String getDescription()
ProductgetDescription in interface Productpublic String getDescription(String selectorString)
ProductThe selector is often a language token, but could also be a regional identifier or some other discriminator.
getDescription in interface Product@Deprecated public String getImagePath()
ProductgetImagePath in interface Product@Deprecated public String getImageUrl()
ProductgetImageUrl in interface Product@Deprecated public ImageResource getThumbnail()
Productnull if no thumbnail was found.getThumbnail in interface Productpublic String getThumbnailUrl()
ProductgetThumbnailUrl in interface Productpublic String getThumbnailUrl(int width)
ProductgetThumbnailUrl in interface Productpublic String getThumbnailUrl(String selectorString)
selectorString contains "image", it returns the thumbnail based on the product image by
calling getImage(), otherwise it returns the thumbnail based on the product asset by calling
getAsset()getThumbnailUrl in interface Productpublic ImageResource getImage()
Productnull if no image was found.public Resource getAsset()
Productnull if no asset was found.public List<ImageResource> getImages()
Productpublic List<Resource> getAssets()
Productpublic List<Resource> getAssets(List<String> mimeTypes)
mimeTypes - public <T> T getProperty(String name, Class<T> type)
ProductgetProperty in interface Productname - The property nametype - The type the property value should be converted topublic <T> T getProperty(String name, String selectorString, Class<T> type)
ProductThe selector is often a language token, but could also be a regional identifier or some other discriminator.
getProperty in interface Productpublic Iterator<Product> getVariants() throws CommerceException
Product
coat/
coat-blue/
coat-blue-S
coat-blue-M
coat-green/
coat-green-S
it must return [coat-blue-S, coat-blue-M, coat-green-S] whether called
from the Product representing coat or coat-green-S.getVariants in interface ProductCommerceExceptionpublic boolean axisIsVariant(String axis)
ProductaxisIsVariant in interface Productaxis - The name of the propertytrue if the given axis is variantpublic Iterator<Product> getVariants(VariantFilter filter) throws CommerceException
ProductVariantFilter.
Example usages:
To get the complete list of sizes, irrespective of color:
Iterator iter = product.getVariants(new EnumerateAxisFilter("size"));
To get the list of sub-variants of the color "blue":
Iterator iter = product.getVariants(new AxisFilter("color", "blue"));
getVariants in interface ProductCommerceExceptionVariantFilter,
EnumerateAxisFilter,
AxisFilterpublic Iterator<String> getVariantAxes()
Product["color", "size"].getVariantAxes in interface Productpublic Product getBaseProduct() throws CommerceException
ProductProduct which is already the base, will return this.getBaseProduct in interface ProductProductCommerceExceptionpublic Product getPIMProduct() throws CommerceException
ProductgetPIMProduct in interface ProductProductCommerceExceptionpublic static boolean isAVariant(Resource resource)
resource - public static boolean isABaseProduct(Resource resource)
resource - public static boolean isAProductOrVariant(Resource resource)
resource - public <AdapterType> AdapterType adaptTo(Class<AdapterType> type)
AdapterManager to adapt this object to
the desired type.
This method implements a cache of adapters to improve performance. That is repeated calls to this method with the same class will result in the same object to be returned.
adaptTo in interface AdaptableadaptTo in class SlingAdaptableAdapterType - The generic type to which this resource is adapted
totype - The Class object of the target type, such as
javax.jcr.Node.class or
java.io.File.classnull if the resource cannot
adapt to the requested type"Copyright © 2010 - 2017 Adobe Systems Incorporated. All Rights Reserved"