public interface Product extends Adaptable
Product
interface reflects resources that represent products and
their variants in an e-commerce system.
Products have properties. Properties which drive product variation are known as
"variant axes". Note that this does not include properties which change as a
result of variation, such as "shipping-weight" or "price".
Each product variation must have a unique resource. Hierarchy above those leaf
resources may or may not be present, depending on the PIM architecture, but if
present should also be modelled by the Product interface.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
RESOURCE_TYPE_PRODUCT
Base resource type for products.
|
Modifier and Type | Method and Description |
---|---|
boolean |
axisIsVariant(java.lang.String axis)
Tests a single axis (property) for variation.
|
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.
|
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.
since 5.6.1; use
getImage() instead. |
java.util.List<ImageResource> |
getImages()
Get all the images for this product.
|
java.lang.String |
getImageUrl()
Deprecated.
since 5.6.1; use
getImage() instead. |
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.
|
java.lang.String |
getSKU()
Get a unique identifier for a product variation.
|
ImageResource |
getThumbnail()
Deprecated.
since 6.1; use
getThumbnailUrl() instead. |
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)
Returns the URL to the product's thumbnail image, based on the given selector string.
|
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 . |
static final java.lang.String RESOURCE_TYPE_PRODUCT
java.lang.String getPath()
java.lang.String getPagePath()
java.lang.String getSKU()
java.lang.String getTitle()
java.lang.String getTitle(java.lang.String selectorString)
The selector is often a language token, but could also be a regional identifier or some other discriminator.
selectorString
- java.lang.String getDescription()
java.lang.String getDescription(java.lang.String selectorString)
The selector is often a language token, but could also be a regional identifier or some other discriminator.
selectorString
- java.lang.String getThumbnailUrl()
java.lang.String getThumbnailUrl(int width)
width
- java.lang.String getThumbnailUrl(java.lang.String selectorString)
The selector is often a size or orientation specification, but could also be used for language- or region-specific images.
selectorString
- Resource getAsset()
null
if no asset was found.java.util.List<Resource> getAssets()
ImageResource getImage()
null
if no image was found.java.util.List<ImageResource> getImages()
<T> T getProperty(java.lang.String name, java.lang.Class<T> type)
name
- The property nametype
- The type the property value should be converted to<T> T getProperty(java.lang.String name, java.lang.String selectorString, java.lang.Class<T> type)
The selector is often a language token, but could also be a regional identifier or some other discriminator.
T
- name
- selectorString
- type
- java.util.Iterator<java.lang.String> getVariantAxes()
["color", "size"]
.boolean axisIsVariant(java.lang.String axis)
axis
- The name of the propertytrue
if the given axis is variantjava.util.Iterator<Product> getVariants() throws CommerceException
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
.CommerceException
java.util.Iterator<Product> getVariants(VariantFilter filter) throws CommerceException
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"));
CommerceException
VariantFilter
,
EnumerateAxisFilter
,
AxisFilter
Product getBaseProduct() throws CommerceException
Product
which is already the base, will return this
.Product
CommerceException
Product getPIMProduct() throws CommerceException
Product
CommerceException
@Deprecated java.lang.String getImageUrl()
getImage()
instead.@Deprecated java.lang.String getImagePath()
getImage()
instead.@Deprecated ImageResource getThumbnail()
getThumbnailUrl()
instead.null
if no thumbnail was found."Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"