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, unsetAdapterManager
public AbstractJcrProduct(Resource resource)
resource
- the Resource storing the product (or variant) infopublic java.lang.String getPath()
Product
public java.lang.String getPagePath()
Product
getPagePath
in interface Product
public java.lang.String getTitle()
Product
public java.lang.String getTitle(java.lang.String selectorString)
Product
The selector is often a language token, but could also be a regional identifier or some other discriminator.
public java.lang.String getDescription()
Product
getDescription
in interface Product
public java.lang.String getDescription(java.lang.String selectorString)
Product
The 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()
Product
getImagePath
in interface Product
@Deprecated public java.lang.String getImageUrl()
Product
getImageUrl
in interface Product
@Deprecated public ImageResource getThumbnail()
Product
null
if no thumbnail was found.getThumbnail
in interface Product
public java.lang.String getThumbnailUrl()
Product
getThumbnailUrl
in interface Product
public java.lang.String getThumbnailUrl(int width)
Product
getThumbnailUrl
in interface Product
public 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 Product
public ImageResource getImage()
Product
null
if no image was found.public Resource getAsset()
Product
null
if no asset was found.public java.util.List<ImageResource> getImages()
Product
public java.util.List<Resource> getAssets()
Product
public 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)
Product
getProperty
in interface Product
name
- 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)
Product
The selector is often a language token, but could also be a regional identifier or some other discriminator.
getProperty
in interface Product
public java.util.Iterator<Product> getVariants() throws CommerceException
Product
coat/ coat-blue/ coat-blue-S coat-blue-M coat-green/ coat-green-Sit 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 Product
CommerceException
public boolean axisIsVariant(java.lang.String axis)
Product
axisIsVariant
in interface Product
axis
- The name of the propertytrue
if the given axis is variantpublic java.util.Iterator<Product> getVariants(VariantFilter filter) throws CommerceException
Product
VariantFilter
.
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 Product
CommerceException
VariantFilter
,
EnumerateAxisFilter
,
AxisFilter
public java.util.Iterator<java.lang.String> getVariantAxes()
Product
["color", "size"]
.getVariantAxes
in interface Product
public Product getBaseProduct() throws CommerceException
Product
Product
which is already the base, will return this
.getBaseProduct
in interface Product
Product
CommerceException
public Product getPIMProduct() throws CommerceException
Product
getPIMProduct
in interface Product
Product
CommerceException
public 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 Adaptable
adaptTo
in class SlingAdaptable
AdapterType
- 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.class
null
if the resource cannot
adapt to the requested typepublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"