public interface ProductProjection extends ProductLike<ProductProjection,Product>, Referenceable<Product>, Versioned<Product>
ProductProjection
s are views of Product
s.
To create, update or delete ProductProjection
s you have to use the
Product
lifecycle classes.
Operations:
ProductProjectionByIdGet
ProductProjection
for a method but you have a product,
you can transform a product into a product projection:
final Product product = getProduct(); final ProductProjection staged = product.toProjection(ProductProjectionType.STAGED); assertThat(staged).overridingErrorMessage("staged is always present").isNotNull(); assertThat(staged.getName()).isEqualTo(product.getMasterData().getStaged().getName()); final ProductProjection current = product.toProjection(ProductProjectionType.CURRENT); assertThat(current).overridingErrorMessage("current can be empty").isNull();
See the test code.
toReference()
returns not are reference to a ProductProjection
but to a Product
.Modifier and Type | Method and Description |
---|---|
default Optional<ProductVariant> |
findFirstMatchingVariant()
Finds the first matching variant according to the search criteria used in the search request, if any.
|
default List<ProductVariant> |
findMatchingVariants()
Finds all variants that match the search criteria used in the search request, if any.
|
default Optional<ProductVariant> |
findVariant(ByIdVariantIdentifier identifier) |
default Optional<ProductVariant> |
findVariantBySku(String sku)
Finds a variant by SKU.
|
default List<ProductVariant> |
getAllVariants()
Gets all variants in the product including the master variant as first element in the list.
|
Set<Reference<Category>> |
getCategories() |
CategoryOrderHints |
getCategoryOrderHints() |
LocalizedString |
getDescription() |
String |
getKey()
Key of the product.
|
ProductVariant |
getMasterVariant()
Returns the master variant.
|
LocalizedString |
getMetaDescription() |
LocalizedString |
getMetaKeywords() |
LocalizedString |
getMetaTitle() |
LocalizedString |
getName() |
ReviewRatingStatistics |
getReviewRatingStatistics() |
SearchKeywords |
getSearchKeywords() |
LocalizedString |
getSlug() |
Reference<State> |
getState() |
default ProductVariant |
getVariant(int variantId)
Finds a product variant by id.
|
default ProductVariant |
getVariantOrMaster(int variantId)
Finds a product variant by id and returns the master variant if not variant with the id is present.
|
List<ProductVariant> |
getVariants()
Gets the variants which are not identical to the master variant.
|
Boolean |
hasStagedChanges() |
Boolean |
isPublished() |
default Reference<Product> |
toReference()
Creates a reference to this resource, the reference may not be filled.
|
static com.fasterxml.jackson.core.type.TypeReference<ProductProjection> |
typeReference()
Creates a container which contains the full Java type information to deserialize this class from JSON.
|
getProductType, getTaxCategory
getCreatedAt, getId, getLastModifiedAt, getVersion
getId
metaAttributesOf, metaAttributesOf
hasSameIdAs, toResourceIdentifier
Boolean hasStagedChanges()
Boolean isPublished()
default Reference<Product> toReference()
Referenceable
toReference
in interface Referenceable<Product>
static com.fasterxml.jackson.core.type.TypeReference<ProductProjection> typeReference()
@Nullable LocalizedString getDescription()
ProductVariant getMasterVariant()
getAllVariants()
,
getVariants()
,
ChangeMasterVariant
@Nullable LocalizedString getMetaDescription()
@Nullable LocalizedString getMetaKeywords()
@Nullable LocalizedString getMetaTitle()
LocalizedString getName()
LocalizedString getSlug()
List<ProductVariant> getVariants()
getMasterVariant()
getAllVariants()
,
getMasterVariant()
default List<ProductVariant> getAllVariants()
getMasterVariant()
,
getVariants()
default Optional<ProductVariant> findVariant(ByIdVariantIdentifier identifier)
default Optional<ProductVariant> findVariantBySku(String sku)
sku
- the sku for the variantdefault List<ProductVariant> findMatchingVariants()
default Optional<ProductVariant> findFirstMatchingVariant()
@Nullable default ProductVariant getVariant(int variantId)
variantId
- the id of the variant to findid
getVariantOrMaster(int)
default ProductVariant getVariantOrMaster(int variantId)
variantId
- the id of the variant to findgetVariant(int)
SearchKeywords getSearchKeywords()
@Nullable CategoryOrderHints getCategoryOrderHints()
@Nullable ReviewRatingStatistics getReviewRatingStatistics()
getReviewRatingStatistics
in interface ProductLike<ProductProjection,Product>
@Nullable Reference<State> getState()
getState
in interface ProductLike<ProductProjection,Product>
@Nullable String getKey()
ProductLike
getKey
in interface ProductLike<ProductProjection,Product>
getKey
in interface WithKey
SetKey
,
ProductByKeyGet
,
ProductProjectionByKeyGet
,
ProductDeleteCommand.ofKey(String, Long)
,
ProductUpdateCommand.ofKey(String, Long, List)
,
ProductUpdateCommand.ofKey(String, Long, UpdateAction)