@ConsumerType 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(java.lang.Class<AdapterType> type)
Calls into the registered
AdapterManager to adapt this object to
the desired type. |
boolean |
axisIsVariant(java.lang.String axis)
Tests a single axis (property) for variation.
|
boolean |
equals(java.lang.Object obj) |
Resource |
getAsset()
Get the primary asset for this product, or
null if no asset was found. |
java.util.List<Resource> |
getAssets()
Get all the assets for this product.
|
java.util.List<Resource> |
getAssets(java.util.List<java.lang.String> mimeTypes)
Returns the assets filtered by the mime type
|
Product |
getBaseProduct()
Returns the product which forms the base of a set of variations.
|
java.lang.String |
getDescription()
Returns the product's description.
|
java.lang.String |
getDescription(java.lang.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. |
java.lang.String |
getImagePath()
Deprecated.
|
java.util.List<ImageResource> |
getImages()
Get all the images for this product.
|
java.lang.String |
getImageUrl()
Deprecated.
|
java.lang.String |
getPagePath()
Get the path of the parent page which renders the product/variation.
|
java.lang.String |
getPath()
Get the underlying resource's path.
|
Product |
getPIMProduct()
Returns the PIM Product (under /var/commerce/products) which stores this product's
data.
|
<T> T |
getProperty(java.lang.String name,
java.lang.Class<T> type)
Returns a product property.
|
<T> T |
getProperty(java.lang.String name,
java.lang.String selectorString,
java.lang.Class<T> type)
Return a product property based on the given selector.
|
ImageResource |
getThumbnail()
Deprecated.
|
java.lang.String |
getThumbnailUrl()
Returns the URL to the product's thumbnail image.
|
java.lang.String |
getThumbnailUrl(int width)
Returns the URL to the product's thumbnail image, resized to the specified width.
|
java.lang.String |
getThumbnailUrl(java.lang.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() |
java.lang.String |
getTitle()
Returns the product's title.
|
java.lang.String |
getTitle(java.lang.String selectorString)
Returns the product's title based on the given selector.
|
java.util.Iterator<java.lang.String> |
getVariantAxes()
Returns an iterator over the property names of the variant axes.
|
java.util.Iterator<Product> |
getVariants()
Returns an iterator over the list of all product variations to which this
particular product/variant belongs.
|
java.util.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 java.lang.String getPath()
Productpublic java.lang.String getPagePath()
ProductgetPagePath in interface Productpublic java.lang.String getTitle()
Productpublic java.lang.String getTitle(java.lang.String selectorString)
ProductThe selector is often a language token, but could also be a regional identifier or some other discriminator.
public java.lang.String getDescription()
ProductgetDescription in interface Productpublic java.lang.String getDescription(java.lang.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 java.lang.String getImagePath()
ProductgetImagePath in interface Product@Deprecated public java.lang.String getImageUrl()
ProductgetImageUrl in interface Product@Deprecated public ImageResource getThumbnail()
Productnull if no thumbnail was found.getThumbnail in interface Productpublic java.lang.String getThumbnailUrl()
ProductgetThumbnailUrl in interface Productpublic java.lang.String getThumbnailUrl(int width)
ProductgetThumbnailUrl in interface Productpublic java.lang.String getThumbnailUrl(java.lang.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 java.util.List<ImageResource> getImages()
Productpublic java.util.List<Resource> getAssets()
Productpublic java.util.List<Resource> getAssets(java.util.List<java.lang.String> mimeTypes)
mimeTypes - public <T> T getProperty(java.lang.String name,
java.lang.Class<T> type)
ProductgetProperty in interface Productname - The property nametype - The type the property value should be converted topublic <T> T getProperty(java.lang.String name,
java.lang.String selectorString,
java.lang.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 java.util.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(java.lang.String axis)
ProductaxisIsVariant in interface Productaxis - The name of the propertytrue if the given axis is variantpublic java.util.Iterator<Product> getVariants(VariantFilter filter) throws CommerceException
ProductVariantFilter.
Example usages:
To get the complete list of sizes, irrespective of color:
Iterator<Product> iter = product.getVariants(new EnumerateAxisFilter("size"));
To get the list of sub-variants of the color "blue":
Iterator<Product> iter = product.getVariants(new AxisFilter("color", "blue"));
getVariants in interface ProductCommerceExceptionVariantFilter,
EnumerateAxisFilter,
AxisFilterpublic java.util.Iterator<java.lang.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(java.lang.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 typepublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.ObjectCopyright © 2010 - 2023 Adobe. All Rights Reserved